[CMake] PROJECT command / CMAKE_SYSTEM_NAME / MSVC static runtime

damien benoist damien_benoist at yahoo.com
Tue Jan 18 12:32:15 EST 2011


Hi,

My problem is very simmilar to one posted quite a while ago:
(http :// cmake.3232098.n2.nabble.com/CMAKE-PROJECT-command-and-CMAKE-SYSTEM-NAME-td4548795.html)

But I haven't found a solution.

I would like my CMakeLists.txt to load compiler/system
specific parameters in a directory named after
CMAKE_SYSTEM_NAME variable.

In particular, for windows I would like to load
the "Make Override Files" for static runtime build.

The problem is that this has to be done before
the project command and the CMAKE_SYSTEM_NAME
is not set at that time.

The details:

Tried with 2.8.0 2.8.2 and 2.8.3.

I have a the following tree
CMakeLists.txt
sys/CMake.sysopts
sys/<sys>/CMake.sysopts

CMakeLists.txt contains INCLUDE(sys/CMake.sysopts)
sys/CMake.sysopts contains INCLUDE(sys/${CMAKE_SYSTEM_NAME}/CMake.sysopts)

The sys directory holds all system dependents sources,
and I would like it to also hold all system dependent
cmake parameters.

For each system <sys> I have a sys/<sys> directory
(for now Linux/CYGWIN/Windows)

In the case of Windows I want to build with a static runtime.
So I have added "Make Override Files" as described in the FAQ.
(http :// www.cmake.org/Wiki/CMake_FAQ#Make_Override_Files)

sys/Windows/c_flag_overrides.cmake
sys/Windows/cxx_flag_overrides.cmake

and added:
set(CMAKE_USER_MAKE_RULES_OVERRIDE
        ${CMAKE_CURRENT_SOURCE_DIR}/c_flag_overrides.cmake)
set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX
        ${CMAKE_CURRENT_SOURCE_DIR}/cxx_flag_overrides.cmake)
to sys/Windows/CMake.sysopts

As stated in the FAQ this has to be done before the project command,
so in my case it implies to do
INCLUDE(sys/CMake.sysopts) 
and so INCLUDE(sys/${CMAKE_SYSTEM_NAME}/CMake.sysopts)
before the project command.

The problem is that CMAKE_SYSTEM_NAME is not set before
the project command.


Side effect:
sys/CMake.sysopts
does INCLUDE(sys/${CMAKE_SYSTEM_NAME}/CMake.sysopts)
CMAKE_SYSTEM_NAME beeing empty,
sys/CMake.sysopts includes sys//CMake.sysopts

So cmake gets into infinite recursion and crashes (sigsegv)

#0  0x00bbea95 in operator new () from /usr/lib/libstdc++.so.6
#1  0x00b9a0fb in std::string::_Rep::_S_create () from /usr/lib/libstdc++.so.6
#2  0x00b9aef5 in ?? () from /usr/lib/libstdc++.so.6
#3  0x00b9afa7 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string () from /usr/lib/libstdc++.so.6
#4  0x081c819b in cmsys::String::String ()
#5  0x082fe4a1 in cmDefinitions::GetInternal ()
#6  0x082fe694 in cmDefinitions::Get ()
#7  0x081e4adb in cmMakefile::GetDefinition ()
#8  0x082f258e in cmCommandArgumentParserHelper::ExpandVariable ()
#9  0x0839e23b in cmCommandArgument_yyparse ()
#10 0x082f1d75 in cmCommandArgumentParserHelper::ParseString ()
#11 0x081ef9ce in cmMakefile::ExpandVariablesInString ()
#12 0x081f0945 in cmMakefile::ExpandArguments ()
#13 0x082d029b in cmCommand::InvokeInitialPass ()
#14 0x081f2657 in cmMakefile::ExecuteCommand ()
#15 0x081f3223 in cmMakefile::ReadListFile ()
#16 0x08297a6d in cmIncludeCommand::InitialPass ()
#17 0x082d02cb in cmCommand::InvokeInitialPass ()
#18 0x081f2657 in cmMakefile::ExecuteCommand ()
#19 0x081f3223 in cmMakefile::ReadListFile ()
#20 0x08297a6d in cmIncludeCommand::InitialPass ()
#21 0x082d02cb in cmCommand::InvokeInitialPass ()
#22 0x081f2657 in cmMakefile::ExecuteCommand ()
...

Thanks for your help.



      


More information about the CMake mailing list