[CMake] Building an external library based on autotools

2013-03-21 Thread Lucas Soltic
Hello,

I'm having a hard time figuring out which solution to choose to build a library 
(FFmpeg) based on autotools from CMake, and I have the impression I'm going the 
tricky way.

I know how to run the FFmpeg's configure and make scripts with the right 
options from a bash script. I made a CMake function (based on 
add_custom_command()) that is able to run any bash script on both Windows and 
Unix OSs. Thus I could manually (from CMake) launch a FFmpeg build with the 
previous statements.

But the main disadvantage with this solution is the following one: the enabled 
video decoders are defined in a CMake variable (a list) that the user can 
define in the CMake GUI; I would like FFmpeg to be rebuilt only when this 
variable changes, but at the moment FFmpeg is always rebuilt.

FFmpeg is based on autotools (configure, make, etc). I've read a lot about 
add_custom_command(), add_custom_target() and ExternalProject_Add() but I still 
don't know what's the way to go.

The issues I've seen with these are:
- add_custom_command() will be always executed when I build the target that 
needs FFmpeg, even if FFmpeg is already built and that no setting changed
- add_custom_target() is always built too
- ExternalProject_Add() would directly execute the configure command without 
going through my portable bash launcher (see P.S.)

What I would like is my custom build to be dependent on some CMake variables, I 
don't know if it's possible.

Dependencies about some output files isn't the most important to me, because I 
won't be modifying the FFmpeg sources more than once every few months. And the 
FFmpeg sources are already in my repo so I've no need for automatic download.

Regards,
Lucas SOLTIC



P.S.: details about the portable Bash launcher for those who'd like to know:

The portable Bash launcher I made still requires MinGW to be installed if one 
wants to build from Visual Studio, but the user doesn't need to care about any 
command line interpreter. It's composed of 3 files: RunShellCommand.cmake, 
BatchBridgeToShell.bat and RunShellCommand.sh. When being run from Visual 
Studio, RunShellCommand() (defined in RunShellCommand.cmake) will run the bat 
file that will run the shell script. Otherwise RunShellCommand() will directly 
launch RunShellCommand.sh.

RunShellCommand.cmake is as follow:
function(RunShell target phase shell_command)
set(cmd ${ARGV})
list(REMOVE_AT cmd 0 1)

if (MSVC)
add_custom_command(TARGET ${target}
 ${phase}
 COMMAND BatchBridgeToShell ARGS ${MINGW_DIR} ${cmd}
 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) 
else()
add_custom_command(TARGET ${target}
 ${phase}
 COMMAND bash ARGS -c \${cmd}\
 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) 
endif()
endfunction(RunShell)


BatchBridgeToShell.bat is as follows:
PATH %1/msys/1.0/bin;%1/bin;%path%
bash -c ./RunShellCommand.sh --from-batch %*

RunShellCommand.sh is as follows:
#!/bin/bash

# Shell script to run the command given as parameter
# If this script is called from a batch script, it is expected to have 
# two unneeded parameters

if [ $1 == --from-batch ]
  then
shift # drop --from-batch
shift # drop mingw param
fi

# execute
$@


--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

[CMake] How to install files produced by custom targets

2013-09-06 Thread Lucas Soltic
Hello,

Considering that I have a custom target that outputs some libraries and these 
libraries were built using configure+make. The custom library is based on 
autotools. Configure + make are executed by a custom command in the custom 
target.

Is it possible to add a CMake install rule that will execute 'make install' on 
my custom library? So that the install process is automatically handled.

I'm asking that because at the moment I'm finding very hard to install a custom 
library only with classical CMake install rules, because I cannot know in 
advance the names of all the outputs because they have suffixes depending on 
the library version. And I would prefer to avoid hardcoding these versions, so 
that I can easily update my library.

Regards,
Lucas 
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


[CMake] Fwd: How to install files produced by custom targets

2013-09-06 Thread Lucas Soltic
Woops wrong target email. So just so that anyone can read.. here it is:

Début du message réexpédié :

 De : Lucas Soltic lucas.sol...@orange.fr
 Objet : Rép : [CMake] How to install files produced by custom targets
 Date : 6 septembre 2013 19:15:27 UTC+02:00
 À : Petr Kmoch petr.km...@gmail.com
 
 Le 6 sept. 2013 à 14:23, Petr Kmoch petr.km...@gmail.com a écrit :
 
 I just wanted to point out the existence of CMAKE_BUILD_TOOL, as it's 
 related. In your case, however, you're probably better off hardcoding 
 'make'. It should actually be done the same way you run 'make' in your 
 custom command creating the library.
 
 Ok :)
 
 I've looked at install(SCRIPT …) and in the meantime I found 
 install(DIRECTORY …) and I realized it was also solving my problem!
 So at the moment I've a working solution with install(DIRECTORY …)
 
 Thanks a lot for your help! Still good to know that CMake allows executing 
 scrips at install time.
 
 Lucas
 
 On Fri, Sep 6, 2013 at 2:08 PM, Lucas Soltic lucas.sol...@orange.fr wrote:
 
 Le 6 sept. 2013 à 12:58, Petr Kmoch petr.km...@gmail.com a écrit :
 
 Hi Lucas,
 
 you could look into install(CODE ...) or its escaping-hell-avoiding 
 brother, install(SCRIPT ...). The code/script could then be something like 
 execute_process(COMMAND make install ...) or perhaps even 
 execute_process(COMMAND ${CMAKE_BUILD_TOOL} install ...).
 
 Hi Petr,
 
 I guess execute_process() with CMAKE_BUILD_TOOL depends on whether the 
 target build tool supports install ? Will that work when installing from 
 Visual Studio for example?
 
 I need a solution that works both on Windows and Unixes :/
 I'll have a look a install(SCRIPT …).
 
 Thanks!
 Lucas
 
 
 Petr
 
 
 On Fri, Sep 6, 2013 at 11:44 AM, Lucas Soltic lucas.sol...@orange.fr 
 wrote:
 Hello,
 
 Considering that I have a custom target that outputs some libraries and 
 these libraries were built using configure+make. The custom library is 
 based on autotools. Configure + make are executed by a custom command in 
 the custom target.
 
 Is it possible to add a CMake install rule that will execute 'make install' 
 on my custom library? So that the install process is automatically handled.
 
 I'm asking that because at the moment I'm finding very hard to install a 
 custom library only with classical CMake install rules, because I cannot 
 know in advance the names of all the outputs because they have suffixes 
 depending on the library version. And I would prefer to avoid hardcoding 
 these versions, so that I can easily update my library.
 
 Regards,
 Lucas
 --
 
 Powered by www.kitware.com
 
 Please keep messages on-topic and check the CMake FAQ at: 
 http://www.cmake.org/Wiki/CMake_FAQ
 
 Kitware offers various services to support the CMake community. For more 
 information on each offering, please visit:
 
 CMake Support: http://cmake.org/cmake/help/support.html
 CMake Consulting: http://cmake.org/cmake/help/consulting.html
 CMake Training Courses: http://cmake.org/cmake/help/training.html
 
 Visit other Kitware open-source projects at 
 http://www.kitware.com/opensource/opensource.html
 
 Follow this link to subscribe/unsubscribe:
 http://www.cmake.org/mailman/listinfo/cmake
 
 
 
 

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

[CMake] Adding unused files to the generated project

2013-09-22 Thread Lucas Soltic
Hello,

Is it possible to add files that do not belong to any add_executable/library so 
that they're visible in the IDE but not used for building?
That way I could easily work with the generated project on any useful file, 
even if it's not directly used to produce binaries (for example, editing 
CMakeLists.txt from the IDE).

Regards,
Lucas 
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


[CMake] How to tell an executable where to look for libraries it depends on

2014-01-23 Thread Lucas Soltic
Hello,

Is there a CMake rule to tell an executable where to look for its dynamic 
libraries when running? So that the dependencies are correctly loaded at 
runtime.

Regards,
Lucas SOLTIC
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


[CMake] CMAKE_RUNTIME_OUTPUT_DIRECTORY inconsistent between make and Xcode

2014-03-05 Thread Lucas Soltic
Hello,

I have noticed an annoying difference between Xcode and make as far as the 
output directory is concerned.

I have added the following to my CMakeLists.txt:
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

When I run the makefiles generated by CMake with CMAKE_BUILD_TYPE=Debug, I can 
find all of my executables and libraries in build_dir/bin.
However, if I generate an Xcode project with CMake and build my binaries, 
they'll end up partly in build_dir/bin and partly in build_dir/bin/Debug.

With Xcode, the binaries that end up in build_dir/bin/Debug are those generated 
by add_executable/library CMake rules. And the binaries that end up in 
build_dir/bin are those generated by my add_custom_command to which I told to 
put the binaries in ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}.

But if I tell my custom command to put the binaries in 
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}, then it'll be ok with 
Xcode but not make. So what should I do?
Is it an expected behavior?

Thanks,
Lucas
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


[CMake] Reliable binaries output directory

2014-03-07 Thread Lucas Soltic
Hello,

Is there a way to know exactly (through a CMake variable or command) where the 
binaries will be put?

I've defined CMAKE_RUNTIME_OUTPUT_DIRECTORY to put all the executables in the 
same directory, but some generators will use a Debug/Release subdirectory of 
this variable's value, whereas others won't.

Thanks,
Lucas
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] CMAKE_RUNTIME_OUTPUT_DIRECTORY inconsistent between make and Xcode

2014-03-09 Thread Lucas Soltic

Le 9 mars 2014 à 21:19, jmerkow jmer...@gmail.com a écrit :

 I am having a similar issue. 
 
 I generate a number of scripts I configure with the path to the executables. 
 This path is the same when using make, but with XCode or MSVSC they append
 the build type (Debug, Release, RelWithDebInfo, etc). 
 Bascially, this script sets a number of env variables, and adds the the PATH
 so the application can run.
 
 I'm betting this is a common use of configure file, how is it generally
 solved?  I supposed some post build command could be used?
 
 -Jameson

Actually this has been answered in this thread:
http://www.cmake.org/pipermail/cmake/2014-March/057162.html

:)
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


[CMake] How to use LINK_INTERFACE_LIBRARIES

2014-05-24 Thread Lucas Soltic
Hello!

I'm having a hard time at properly using LINK_INTERFACE_LIBRARIES.
From what I understood, setting this property empty for a target avoids 
transitive dependencies linking.

But whatever I try, it doesn't work.
I have created a lib A linked against lib B.
I'm also creating an exe linked against lib A. But I really don't want it to be 
linked against lib B.

Till now I've tried
target_link_libraries(myexe A)
target_link_libraries(myexe LINK_INTERFACE_LIBRARIES )
and
target_link_libraries(myexe A)
set_target_properties(myexe PROPERTIES LINK_INTERFACE_LIBRARIES )
and
target_link_libraries(myexe LINK_INTERFACE_LIBRARIES A)

But in all these cases the exe gets linked against B :( (which causes loading 
issues due to RPATH stuff)
Does someone know how to use this property? (if it's the right one?)

Kind regards,
Lucas
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] How to use LINK_INTERFACE_LIBRARIES

2014-05-24 Thread Lucas Soltic
Le 24 mai 2014 à 18:45, Nils Gladitz nilsglad...@gmail.com a écrit :
 
 On 24.05.2014 18:15, Lucas Soltic wrote:
 Hello!
 
 I'm having a hard time at properly using LINK_INTERFACE_LIBRARIES.
 From what I understood, setting this property empty for a target avoids 
 transitive dependencies linking.
 
 But whatever I try, it doesn't work.
 I have created a lib A linked against lib B.
 I'm also creating an exe linked against lib A. But I really don't want it to 
 be linked against lib B.
 
 Till now I've tried
 target_link_libraries(myexe A)
 target_link_libraries(myexe LINK_INTERFACE_LIBRARIES )
 and
 target_link_libraries(myexe A)
 set_target_properties(myexe PROPERTIES LINK_INTERFACE_LIBRARIES )
 and
 target_link_libraries(myexe LINK_INTERFACE_LIBRARIES A)
 
 But in all these cases the exe gets linked against B :( (which causes 
 loading issues due to RPATH stuff)
 Does someone know how to use this property? (if it's the right one?)
 
 Kind regards,
 Lucas
 
 target_link_libraries(A PRIVATE B) # A links to B but B is not added to the 
 interface of A
 target_link_libraries(myexe A) # myexe links to A without B
 
 Nils

Oh thank you so much that was it!
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

[CMake] find_library and caching

2014-06-15 Thread Lucas Soltic
Hello,

I use a FindSomeLib.cmake script for my project, for which there is a variable 
(let's call it LINK_STATIC) to define if one wants to link   against 
SomeLib statically. The default is to look for dynamic libraries.

The issue is that when first running CMake's configure, the user may have 
forgotten to set LINK_STATIC, so the script finds the dynamic version of 
SomeLib and set a cache entry for it. Then in CMake's GUI the user realizes he 
wants static linking so he sets the LINK_STATIC flag, but at this point 
find_library has already cached the result and won't look again for static 
version of SomeLib.

This ends up with the user thinking he's using static linking, which is not 
what's happening.
I saw in CMake's doc that in order to let find_library search again, I'd need 
to clear the library entry it has found. But if I do this at each CMake 
configure run, it removes the interest of the cache.

Would anyone know about the preferred way to fix this caching issue?
I would be really grateful :)

Thanks,
Lucas
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake


Re: [CMake] find_library and caching

2014-06-15 Thread Lucas Soltic
Le 15 juin 2014 à 20:19, Nils Gladitz nilsglad...@gmail.com a écrit :

 On 15.06.2014 19:33, Lucas Soltic wrote:
 I use a FindSomeLib.cmake script for my project, for which there is a 
 variable (let's call it LINK_STATIC) to define if one wants to link
 against SomeLib statically. The default is to look for dynamic libraries.
 
 The issue is that when first running CMake's configure, the user may have 
 forgotten to set LINK_STATIC, so the script finds the dynamic version of 
 SomeLib and set a cache entry for it. Then in CMake's GUI the user realizes 
 he wants static linking so he sets the LINK_STATIC flag, but at this point 
 find_library has already cached the result and won't look again for static 
 version of SomeLib.
 
 This ends up with the user thinking he's using static linking, which is not 
 what's happening.
 I saw in CMake's doc that in order to let find_library search again, I'd 
 need to clear the library entry it has found. But if I do this at each CMake 
 configure run, it removes the interest of the cache.
 
 Would anyone know about the preferred way to fix this caching issue?
 I would be really grateful :)
 
 
 Perhaps you could use distinct cache variables for static and shared 
 libraries.
 
 e.g.
 
 find_library(FOO_STATIC_LIBRARY ...)
 find_library(FOO_SHARED_LIBRARY ...)
 
 set(FOO_LIBRARIES )
 
 if(FOO_LINK_STATIC)
list(APPEND FOO_LIBRARIES ${FOO_STATIC_LIBRARY})
 else()
list(APPEND FOO_LIBRARIES ${FOO_SHARED_LIBRARY})
 endif()
 
 Nils

Oh my… really interesting idea! Thanks!!

Lucas
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake


Re: [CMake] Running OSX Bundle via open after creation with CMake/CPack

2014-06-23 Thread Lucas Soltic

Le 23 juin 2014 à 03:11, Scott Klum scott.k...@gmail.com a écrit :

 I'm trying to make an OSX bundle using CMake/CPack on OSX that involves 
 OpenCV and Qt (although I don't think those dependencies matter at this 
 point). Everything compiles and the bundle is created fine, and I have a 
 script that modifies the necessary library paths such the executable I'm 
 making works if I run it from the Terminal within the bundle. The problem I'm 
 having is if I try to run the MyApp.app file via the open command or by 
 simply double clicking the app it gives me the error:
 
 LSOpenURLsWithRole() failed with error -10810 for the file /Applications/MyApp
 I've seen other solutions to other LSOpenURLsWithRole() errors involving 
 modifying permissions, but that hasn't helped me. Also, this error code is an 
 unknown error so I'm not sure how to proceed.
 
 
 -- 
 Scott Klum

Hello Scott,

Does anything get printed in the terminal if you type and enter:
/Applications/MyApp.app/Contents/MacOS/MyApp
?-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

[CMake] Creating a relocatable ProjectConfig.cmake when build uses absolute paths

2018-01-10 Thread Lucas Soltic
Hello,

I'm trying to create a relocatable package configuration file but I'm having a 
hard time with absolute paths that are used during the build.
Note that I use CMake 3.10.0.

First of all for the include path I'm using this:
target_include_directories(MyStaticTarget PUBLIC
   $
   $)

This does work but according to the doc it should not : 
https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html?highlight=build_interface#output-expressions
 

The doc of BUILD_INTERFACE says: "Content of ... when the property is exported 
using export(), or when the target is used by another target in the same 
buildsystem. Expands to the empty string otherwise."
So according to the doc, when compiling the target MyTarget, the include dir I 
gave should not be used. Which seems consistent with the other uses of 
INTERFACE wording in CMake language. But it actually behaves like PUBLIC rather 
than INTERFACE. This is fine to me but inconsistent… :)
When exporting the target, the include dir uses what's given in for 
INSTALL_INTERFACE so it works fine. No problem on that part.


The second point is about libraries to link when using my project. My project 
exports a static library that depends on other libraries. These libraries are 
found (when generating my project through cmake) through calls like 
find_package(OpenGL). This provides a variable that contains an absolute 
non-relocatable path.

I've tried doing things like this:
target_link_libraries(MyStaticTarget PRIVATE
  $
  $)

According to https://cmake.org/pipermail/cmake/2016-May/063400.html 
, for static libraries, 
PRIVATE link dependencies become "PUBLIC", which is ok. And I could see that 
the link flag for this "private" dependency got exported in the generated 
config. But the problem is that whatever I put for INSTALL_INTERFACE, it is 
ignored and not written to the generated cmake config file. The generated CMake 
config file just takes into account what I put for BUILD_INTERFACE. Contrary to 
what happened with include directories. And I don't want to use only 
${OpenGL_relocatable_link_flag} because MyStaticTarget can be configured to be 
a dynamic library, in which case the library is really used during link and 
really want to link against the exact library that's referenced.

How can I have ${OpenGL_relocatable_link_flag} be used in the generated cmake 
config file?
Any other solution that would make the generated config relocatable is also 
fine.

Best regards,
Lucas -- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake


Re: [CMake] Recommandation for macOS framework install rules

2018-01-19 Thread Lucas Soltic
Hello,
Should I conclude that there are no recommendations?

Best regards,
Lucas

> Le 17 janv. 2018 à 23:49, Lucas Soltic <lucas.sol...@orange.fr> a écrit :
> 
> Hello,
> 
> By default library install() command uses CMAKE_INSTALL_PREFIX (/usr/local by 
> default) as a base for relative install paths. But when you define install 
> rules for macOS frameworks, it doesn't make much sense to install them there. 
> I'd rather expect something like /Library/Frameworks.
> 
> On the other side, if you have more things to install like a "readme" or 
> documentation that should go into /usr/local/share, it doesn't make sense to 
> have them installed in /Library/Frameworks. So you can't just change 
> CMAKE_INSTALL_PREFIX to be /Library/Frameworks.
> 
> What do you recommend to keep installation rules simple (ie. remain relative) 
> and yet support installation of both frameworks and other things?
> 
> Best regards,
> Lucas
> -- 
> 
> Powered by www.kitware.com
> 
> Please keep messages on-topic and check the CMake FAQ at: 
> http://www.cmake.org/Wiki/CMake_FAQ
> 
> Kitware offers various services to support the CMake community. For more 
> information on each offering, please visit:
> 
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
> 
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
> 
> Follow this link to subscribe/unsubscribe:
> https://cmake.org/mailman/listinfo/cmake

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake


Re: [CMake] Recommandation for macOS framework install rules

2018-01-22 Thread Lucas Soltic
Hello,

The product is a cross-platform API that relies on CMake for the config part. 
We ship static and dynamic libraries for Linux, Windows and macOS. Additionally 
on macOS we want to provide frameworks to ease integration (headers and a few 
dependencies in the bundle framework, etc). In addition to the libraries, with 
also ship documentation, sample codes, etc.

When we ship we do a manual packaging of the files for now. We also have 
install rules if a user executes the install target from his own build of the 
product.

And by default as CMake also installs frameworks relatively to 
CMAKE_INSTALL_PREFIX, they get installed in /usr/local or one of its 
subdirectories. This might be ok for all the other files to install but not for 
frameworks, as documented on 
https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/InstallingFrameworks.html
 
<https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/InstallingFrameworks.html>

Also I don't want to specify an absolute path in the install rule of the 
frameworks, because we generate a Config.cmake file and giving an 
absolute path to install() command makes the generated config non-relocatable. 
It doesn't look to be documented in 
https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#creating-relocatable-packages
 
<https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#creating-relocatable-packages>
 but that's what I noticed.

Finally as we don't ship a .app bundle, we can't install our stuff in it. I 
hope it's clearer, please tell me if you still miss information.

Best regards,
Lucas

> Le 22 janv. 2018 à 17:33, Sean McBride <s...@rogue-research.com> a écrit :
> 
> On macOS, the most usual thing is for your code to be self-contained in your 
> .app bundle.  Perhaps if you described more what kind of thing you are 
> building and why you don't want to do the usual thing, people will have more 
> advice...
> 
> 
> On Fri, 19 Jan 2018 19:44:03 +0100, Lucas Soltic said:
> 
>> Hello,
>> Should I conclude that there are no recommendations?
>> 
>> Best regards,
>> Lucas
>> 
>>> Le 17 janv. 2018 à 23:49, Lucas Soltic <lucas.sol...@orange.fr> a écrit :
>>> 
>>> Hello,
>>> 
>>> By default library install() command uses CMAKE_INSTALL_PREFIX (/usr/
>> local by default) as a base for relative install paths. But when you
>> define install rules for macOS frameworks, it doesn't make much sense to
>> install them there. I'd rather expect something like /Library/Frameworks.
>>> 
>>> On the other side, if you have more things to install like a "readme"
>> or documentation that should go into /usr/local/share, it doesn't make
>> sense to have them installed in /Library/Frameworks. So you can't just
>> change CMAKE_INSTALL_PREFIX to be /Library/Frameworks.
>>> 
>>> What do you recommend to keep installation rules simple (ie. remain
>> relative) and yet support installation of both frameworks and other things?
> 
> 
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake


[CMake] Recommandation for macOS framework install rules

2018-01-17 Thread Lucas Soltic
Hello,

By default library install() command uses CMAKE_INSTALL_PREFIX (/usr/local by 
default) as a base for relative install paths. But when you define install 
rules for macOS frameworks, it doesn't make much sense to install them there. 
I'd rather expect something like /Library/Frameworks.

On the other side, if you have more things to install like a "readme" or 
documentation that should go into /usr/local/share, it doesn't make sense to 
have them installed in /Library/Frameworks. So you can't just change 
CMAKE_INSTALL_PREFIX to be /Library/Frameworks.

What do you recommend to keep installation rules simple (ie. remain relative) 
and yet support installation of both frameworks and other things?

Best regards,
Lucas
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake


Re: [CMake] Recommandation for macOS framework install rules

2018-01-22 Thread Lucas Soltic


> Le 19 janv. 2018 à 20:01, J Decker <d3c...@gmail.com> a écrit :
> 
> 
> 
>> On Fri, Jan 19, 2018 at 10:44 AM, Lucas Soltic <lucas.sol...@orange.fr> 
>> wrote:
>> Hello,
>> Should I conclude that there are no recommendations?
>> 
> I would think if there were platform exceptions they would be modifications 
> to this... 
> 
> https://apimirror.com/cmake~3.8/module/gnuinstalldirs

Thanks for your time :) I didn’t find anything related to frameworks there. But 
I don’t expect GNU-related page to contain anything specific to macOS. Nice 
documentation website though, didn’t know about it.

I also did a grep in CMake modules but didn’t find anything close to a 
framework install prefix.

>> Best regards,
>> Lucas
>> 
>> > Le 17 janv. 2018 à 23:49, Lucas Soltic <lucas.sol...@orange.fr> a écrit :
>> >
>> > Hello,
>> >
>> > By default library install() command uses CMAKE_INSTALL_PREFIX (/usr/local 
>> > by default) as a base for relative install paths. But when you define 
>> > install rules for macOS frameworks, it doesn't make much sense to install 
>> > them there. I'd rather expect something like /Library/Frameworks.
>> >
>> > On the other side, if you have more things to install like a "readme" or 
>> > documentation that should go into /usr/local/share, it doesn't make sense 
>> > to have them installed in /Library/Frameworks. So you can't just change 
>> > CMAKE_INSTALL_PREFIX to be /Library/Frameworks.
>> >
>> > What do you recommend to keep installation rules simple (ie. remain 
>> > relative) and yet support installation of both frameworks and other things?
>> >
>> > Best regards,
>> > Lucas
>> > --
>> >
>> > Powered by www.kitware.com
>> >
>> > Please keep messages on-topic and check the CMake FAQ at: 
>> > http://www.cmake.org/Wiki/CMake_FAQ
>> >
>> > Kitware offers various services to support the CMake community. For more 
>> > information on each offering, please visit:
>> >
>> > CMake Support: http://cmake.org/cmake/help/support.html
>> > CMake Consulting: http://cmake.org/cmake/help/consulting.html
>> > CMake Training Courses: http://cmake.org/cmake/help/training.html
>> >
>> > Visit other Kitware open-source projects at 
>> > http://www.kitware.com/opensource/opensource.html
>> >
>> > Follow this link to subscribe/unsubscribe:
>> > https://cmake.org/mailman/listinfo/cmake
>> 
>> --
>> 
>> Powered by www.kitware.com
>> 
>> Please keep messages on-topic and check the CMake FAQ at: 
>> http://www.cmake.org/Wiki/CMake_FAQ
>> 
>> Kitware offers various services to support the CMake community. For more 
>> information on each offering, please visit:
>> 
>> CMake Support: http://cmake.org/cmake/help/support.html
>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>> 
>> Visit other Kitware open-source projects at 
>> http://www.kitware.com/opensource/opensource.html
>> 
>> Follow this link to subscribe/unsubscribe:
>> https://cmake.org/mailman/listinfo/cmake
> 
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake


Re: [CMake] Swift executables with MACOSX_BUNDLE fail to find libswiftCore.dylib

2018-03-06 Thread Lucas Soltic
If full support for Swift was added to CMake yes why not. But I’m not a CMake 
developer and considering current Swift support it’s a bit early I think. I 
mean Swift support should come as a global feature, not just this specific 
point.

> Le 6 mars 2018 à 11:02, Harry Mallon  a écrit :
> 
> Hi Lucas,
>  
> With Swift there is a required standard dylib that must be included (and 
> Xcode copies by default). So perhaps CMake should automatically add the rpath 
> option to the Xcode command line?
>  
> Harry
>  
> From: Lucas Šoltić 
> Date: Friday, 2 March 2018 at 23:20
> To: Harry Mallon 
> Cc: "cmake@cmake.org" 
> Subject: Re: [CMake] Swift executables with MACOSX_BUNDLE fail to find 
> libswiftCore.dylib
>  
> You miss a runtime search path when linking your executable. And this is what 
> you achieved with install_name_tool with an additional step.
>  
> To avoid this additional step, see 
> https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/RunpathDependentLibraries.html
> or
> https://stackoverflow.com/questions/42613881/adding-run-time-shared-library-search-path-to-executable-at-compile-time-clang
>  
> By the way this is not related to Swift at all.
>  
> Lucas
> 
> Le 2 mars 2018 à 20:12, Harry Mallon  a écrit :
> 
> Hello all,
>  
> When making a pure Swift bundle Xcode automatically copies 
> `libswiftCore.dylib` as follows.
>  
> ```
> ./Tests/SwiftOnly/Debug/SwiftOnly.app
> └── Contents
> ├── Frameworks
> │   └── libswiftCore.dylib
> ├── Info.plist
> ├── MacOS
> │   └── SwiftOnly
> ├── PkgInfo
> └── Resources
> └── libswiftRemoteMirror.dylib
> ```
> When I try to run the output I get a dynamic linking error. I can reproduce 
> this by adding MACOSX_BUNDLE to `./Tests/SwiftOnly/CMakeLists.txt` (in the 
> CMake source tree) in `add_executable` and trying to run the result.
>  
> ```
> % ./Tests/SwiftOnly/Debug/SwiftOnly.app/Contents/MacOS/SwiftOnly
> dyld: Library not loaded: @rpath/libswiftCore.dylib
>   Referenced from: 
> .../Tests/SwiftOnly/Debug/SwiftOnly.app/Contents/MacOS/SwiftOnly
>   Reason: image not found
> zsh: abort  ./Tests/SwiftOnly/Debug/SwiftOnly.app/Contents/MacOS/SwiftOnly
> ```
>  
> It seems that the rpath should be set to `@loader_path/../Frameworks`. I am 
> not a Swift maestro so not exactly sure on the details of how this works. 
> After running `install_name_tool -add_rpath "@loader_path/../Frameworks" 
> ./Tests/SwiftOnly/Debug/SwiftOnly.app/Contents/MacOS/SwiftOnly` it runs fine.
>  
> Does anyone have any idea what to do? Is it a missing CMake Swift feature? We 
> are currently working around it by manually adding the rpath with a cmake 
> step.
>  
> Harry
> Harry Mallon
> Senior Software Engineer
> 
> 
> 
> T +44 203 7000 989 
> 60 Poland Street | London | England | W1F 7NT
> 
> 
> Three Billboards
> Blade Runner 2049
>  I, Tonya
>  
> 
> -- 
> 
> Powered by www.kitware.com
> 
> Please keep messages on-topic and check the CMake FAQ at: 
> http://www.cmake.org/Wiki/CMake_FAQ
> 
> Kitware offers various services to support the CMake community. For more 
> information on each offering, please visit:
> 
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
> 
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
> 
> Follow this link to subscribe/unsubscribe:
> https://cmake.org/mailman/listinfo/cmake
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake