[CMake] disabling features such as C++
Reggie Burnett
reggie at bytefx.com
Mon Feb 6 15:13:18 EST 2006
Guys,
Can you tell me how to disable a feature such as exception handling for a
project under cmake control? This is on Windows using Visual 7 and 8.
Looking in the platform files, I see that /EHsc is automatically added to
the build flags variable but I can't seem to find a good way to remove it.
I've tried the brute force approach like so:
# replace /MDd with /MTd
IF(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR CMAKE_GENERATOR MATCHES
"Visual Studio 8")
STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG_INIT
${CMAKE_CXX_FLAGS_DEBUG_INIT})
STRING(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG_INIT
${CMAKE_C_FLAGS_DEBUG_INIT})
STRING(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
STRING(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE
${CMAKE_CXX_FLAGS_RELEASE})
STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
# remove support for Exception handling
STRING(REPLACE "/GX" "" CMAKE_CXX_FLAGS_INIT ${CMAKE_CXX_FLAGS_INIT})
STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_INIT ${CMAKE_CXX_FLAGS_INIT})
ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 7" OR CMAKE_GENERATOR MATCHES
"Visual Studio 8")
However when I print out the variables with this:
MESSAGE("c init = ${CMAKE_C_FLAGS_INIT}")
MESSAGE("c debug init = ${CMAKE_C_FLAGS_DEBUG_INIT}")
MESSAGE("c release = ${CMAKE_C_FLAGS_RELEASE}")
MESSAGE("c debug = ${CMAKE_C_FLAGS_DEBUG}")
MESSAGE("c++ init = ${CMAKE_CXX_FLAGS_INIT}")
MESSAGE("c++ debug init = ${CMAKE_CXX_FLAGS_DEBUG_INIT}")
MESSAGE("c++ release = ${CMAKE_CXX_FLAGS_RELEASE}")
MESSAGE("c++ debug = ${CMAKE_CXX_FLAGS_DEBUG}")
I see that none of the variables includes /EHsc and yet when I load the
generated solution up into Visual Studio, there it is!! I'm not sure what
I am missing.
Thanks for the help
Reggie
More information about the CMake
mailing list