On 09/26/2017 05:05 PM, Raffi Enficiaud wrote:
> Is it possible to source the default setup and to override some parts 
> when a toolchain is given on the command line?

The toolchain file is loaded very early, before any of the platform
information files.  It is supposed to provide information, not consume it.
It is loaded too early to even know CMAKE_SYSTEM_NAME, because it is
supposed to provide this value.

> Also, is it possible to check for policies directly from the toolchain 
> file, or is it too early?

In a project that starts with `cmake_minimum_required(...)` as its first
call (the recommended approach) then policies it sets will be available
when the toolchain file is first loaded by a following `project()` or
`enable_language()` command.  However, toolchain files are not meant to
be general-purpose infrastructure shared by many projects.  They are
meant to be specific to a project and host machine.  Common info about
a platform belongs in CMake's modules, e.g. a Platform/iOS.cmake module
for use with CMAKE_SYSTEM_NAME set to "iOS".  Lacking that, a toolchain
file trying to work without it will undoubtedly need to be hacky.

> This is what I added in the toolchain file, but I feel like this is too 
> hacky:
> 
> set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR TRUE)
> set(CMAKE_INSTALL_NAME_DIR "@rpath/")
> set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
> set(CMAKE_INSTALL_RPATH "@rpath/")

If that is universally needed when deploying to iOS then CMake should
be taught this information in a corresponding platform file.  Keeping
it in the toolchain file may work but is an example of the hacky nature
discussed above.  OTOH this looks project-specific to me.  One could
use `@executable_path/` in INSTALL_NAME_DIR for everything and not need
any rpath.

> and I need to also do this:
> set_target_properties(mymainexecutable
>    PROPERTIES
>      BUILD_WITH_INSTALL_RPATH TRUE
>      INSTALL_RPATH "@executable_path/"
> )

This encodes knowledge of the relative install destination of the
libraries to the executable, which only the project code itself
can know.

-Brad
-- 

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-developers

Reply via email to