I'm pretty new to cmake. I'm using the following:
cmake -DUSE_OLD_CODE:BOOL=FALSE
This works fine. But when I change the FALSE
to TRUE
, the compiler seems to think that USE_OLD_CODE
is a file and then complains that it cannot find it.
Below is CMakeLists.txt
cmake_minimum_required(VERSION 3.5.1)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_compile_options(-std=c++11 /W4 /wd"4127" /wd"4201" /MP)
IF(USE_OLD_CODE) add_compile_options(/D "USE_OLD_CODE") ENDIF(USE_OLD_CODE)
set( SOURCES "main.cpp" )
set (OLD_CODE_SOURCES "OldCode.cpp" )
set (NEW_CODE_SOURCES "NewCode.cpp" )
IF(USE_OLD_CODE) set (SOURCES ${SOURCES} "${OLD_CODE_SOURCES}") ELSE(USE_OLD_CODE) set (SOURCES ${SOURCES} "${NEW_CODE_SOURCES}") ENDIF(USE_OLD_CODE)
IF(WIN32) add_executable(${EXECUTABLE} WIN32 ${SOURCES}) ELSEIF(UNIX) add_executable(${EXECUTABLE} ${SOURCES}) ENDIF(WIN32)
Any ideas what I am doing wrong?
thanks
james
FALSE
part totrue
or theBOOL
part totrue
? – SimpleCMakeLists.txt
code also that translates the CMake variable to something your compiler gets. – Florian