Hi all,

>From my understanding, the toolchain files are only inteneded for
cross-compilation and I'm afraid you will run in some kind of troubles if
you try to use it for something else.

As far I know, this feature you describe does not exist in CMake.

However I have a piece of CMake code that does what you want. Please find
it below. Maybe this can help you.
- By default, it loads the settings from file Local_Settings.cmake. It is
ignored silently if it does not exist
- You can use -DLOCAL_SETTINGS=My_Other_Local_Settings.cmake on the CMake
command line to specify a different file

In a separate file Load_Local_Settings.cmake:


# Default name for Local Settings file

set(DEFAULT_LOCAL_SETTINGS_FILE "${CMAKE_SOURCE_DIR}/Local_Settings.cmake")


# CMake cache option

set(LOCAL_SETTINGS "" CACHE FILEPATH "Path to a file containing Local
Settings to load")


# Set LOCAL_SETTINGS_FILE variable

if(LOCAL_SETTINGS)

  # If cache variable is set, use it and fails if it is not valid

  if(EXISTS "${LOCAL_SETTINGS}" AND NOT IS_DIRECTORY "${LOCAL_SETTINGS}")

    set(LOCAL_SETTINGS_FILE "${LOCAL_SETTINGS}")

  else()

    message(FATAL_ERROR "'${LOCAL_SETTINGS}' is not a valid file for
LOCAL_SETTINGS")

  endif()

else()

  # Otherwise, try default filename, and ignore silently if it does not exist

  if(EXISTS "${DEFAULT_LOCAL_SETTINGS_FILE}" AND NOT IS_DIRECTORY
"${DEFAULT_LOCAL_SETTINGS_FILE}")

    set(LOCAL_SETTINGS_FILE "${DEFAULT_LOCAL_SETTINGS_FILE}")

  else()

    set(LOCAL_SETTINGS_FILE "")

  endif()

endif()


# Load the settings from the file if variable is defined

if(LOCAL_SETTINGS_FILE)

  message(STATUS "Using Local Settings from '${LOCAL_SETTINGS_FILE}'")

  include("${LOCAL_SETTINGS_FILE}")

endif()



Then, in your main CMakeLists.txt, just add:


# Load Local Settings

include( Load_Local_Settings.cmake )



For example, in my Local_Settings.cmake file, I put things like:


set(EIGEN3_ROOT "/path/to/eigen/install" CACHE STRING "")

# You can use environment variables too

set(BOOST_ROOT "$ENV{EBROOTBOOST}" CACHE STRING "")




I hope this helps.


Best regards,


Xavier



On Tue, Aug 8, 2017 at 9:31 PM, Lectem <lec...@gmail.com> wrote:

> I think that you are looking for the toolchain files :
>
> https://cmake.org/cmake/help/v3.0/manual/cmake-toolchains.7.html
>
>
>
> The other option is to use a cmake script to specify your variables which
> includes CMakelists.txt (or the other way around if you can modify the
> CMakelists.txt). This would be quite similar to ctests scripts.
>
> Some good examples are in Daniel Pfeifer’s « Effective cmake » talk
> https://github.com/boostcon/cppnow_presentations_2017/blob/
> master/05-19-2017_friday/effective_cmake__daniel_pfeifer__
> cppnow_05-19-2017.pdf
>
>
>
>
>
> *De : *Brian Davis <bitmi...@gmail.com>
> *Envoyé le :*mardi 8 août 2017 20:09
> *À : *cmake Mailing List <cmake@cmake.org>
> *Objet :*[CMake] CMake equivalent to Boost.Build site-config.jam
> oruser-config.jam
>
>
>
>
> Is there a CMake equivalent to a site-config.jam or user-config.jam
>
> http://www.boost.org/build/doc/html/bbv2/recipies/site-config.html
>
> basically a CMake file the user can put in a project directory that CMake
> will read first when using cmake-gui that allows user to specify stuff they
> don't want to have to keep specifying in cmake-gui each "delete cache"
>
> such as
>
> set( CMAKE_INSTALL_PREFIX ${CURRENT_LIST_DIR}/install CACHE STRING ""
> FORCE)
> set( CMAKE_DEBUG_POSTFIX d CACHE STRING "" FORCE )
>
> There is cmake.exe
>
>
>
> -C <initial-cache>
>
> but requires command line
>
> come to think of it would be nice if
>
> set( CMAKE_GENERATOR_PLATFORM "Visual Studio 12 2013 Win64" )
>
> in desired user config file and CMake would just "make it so" on clicking
> Generate.
>
> I can do this with my own projects, by implementing it myself, but when
> checking out 3rd party projs they can be all over the map on config
> allowing a user-config.cmake would provide mechanism to tame the config
> problems.
>
> Desired workflow
>
> 1) Checkout 3rd party proj
>
> 2) put a CMakeUser.txt or whatever file per project
>
> 3) Run CMake GUI Generate
>
> 4) Click Open Project
>
> 5) Change whatever manual bits in in gui
>
> 6) Update project suing git witch branches versions
>
> 7) Delete Cache
>
> 8) Return to 3
>
> 9) Doopy doopy doo whatever else
>
>
>
>
>
>
>
> --
>
> 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/opensou
> rce/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
>



-- 
Dr Xavier BESSERON
Research associate
FSTC, University of Luxembourg
Campus Belval, Office MNO E04 0415-040
Phone: +352 46 66 44 5418 <+352%2046%2066%2044%205418>
http://luxdem.uni.lu/
-- 

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

Reply via email to