Preload CMake script for cache

I run cmake with -C mysettings.cmake.

Myfile.cmake content

set(CMAKE_INSTALL_PREFIX "C:/install/mylib" STRING) 

Everything is generated, but it seems the -C mysettings.cmake variable is not set. It is still installed in the default directory.

Cmake prints the message "loading the source cache file .. /../script/cmake/mysettings.cmake" without errors.

Full call:

 cmake -C ../../script/cmake/mysettings.cmake -G "Visual Studio 9 2008" ../../source/mylib 

Is there something wrong with my syntax?

+4
source share
1 answer

From the CMake manual:

This file should be a CMake script containing SET commands that use the CACHE parameter, and not a cache format file.

So your myfile.cmake should look something like this:

 set(CMAKE_INSTALL_PREFIX "C:/install/mylib" CACHE PATH "") 
+4
source

Source: https://habr.com/ru/post/1490941/


All Articles