Hi,
I'm trying to set up cmake for my visual studio project.. I' ve set it up so it 
works fine for make files, but got some problems setting it up as I want it for 
visual studio.
1.
I'm setting up different visual studio configurations so I have DebugOpenGL, 
DebugDirectX, ReleaseOpenGL and ReleaseDirectX. And I want to set special 
defines for eachof the configurations, USE_OPENGL, USE_DIRECTX , but I cant 
figure out how to do it? I know for QMake you can do this:

!build_pass:addExclusiveBuilds(use_opengl, OpenGL , use_directx, 
DirectX)build_pass {    CONFIG(use_opengl, 
use_opengl|use_directx):DEFINES+=USE_OPENGL    else:DEFINES+=USE_DIRECTX}
Is it possible to do something similar with cmake? Note that this is not the 
normal debug/release flag you give to cmake, but different configurations in 
visual studio.
This is how I set up the configurations:
if(CMAKE_CONFIGURATION_TYPES AND MSVC)  set(CMAKE_CONFIGURATION_TYPES 
"DebugOpenGL;ReleaseOpenGL;DebugDirectX;ReleaseDirectX")  
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING       
"Reset the configurations to what we need"      FORCE)          #DebugOpenGL 
flags      set(CMAKE_CXX_FLAGS_DEBUGOPENGL "/D_DEBUG /MDd /Zi /Ob0 /Od /RTC1" 
CACHE STRING "Flags used by the C++ compiler during maintainer builds." FORCE)  
     set(CMAKE_C_FLAGS_DEBUGOPENGL "/D_DEBUG /MDd /Zi  /Ob0 /Od /RTC1" CACHE 
STRING "Flags used by the C compiler during maintainer builds." FORCE)  
set(CMAKE_EXE_LINKER_FLAGS_DEBUGOPENGL "/debug /INCREMENTAL" CACHE STRING 
"Flags used for linking binaries during maintainer builds." FORCE )   
set(CMAKE_SHARED_LINKER_FLAGS_DEBUGOPENGL "/debug /INCREMENTAL" CACHE STRING 
"Flags used by the shared libraries linker during maintainer builds." FORCE )
        #ReleaseOpenGL flags    set(CMAKE_CXX_FLAGS_RELEASEOPENGL "/MD /O2 /Ob2 
/D NDEBUG" CACHE STRING "Flags used by the C++ compiler during maintainer 
builds." FORCE)       set(CMAKE_C_FLAGS_RELEASEOPENGL "/MD /O2 /Ob2 /D NDEBUG" 
CACHE STRING "Flags used by the C compiler during maintainer builds." FORCE)   
set(CMAKE_EXE_LINKER_FLAGS_RELEASEOPENGL "/INCREMENTAL:NO" CACHE STRING "Flags 
used for linking binaries during maintainer builds." FORCE )     
set(CMAKE_SHARED_LINKER_FLAGS_RELEASEOPENGL "/INCREMENTAL:NO" CACHE STRING 
"Flags used by the shared libraries linker during maintainer builds." FORCE )   
             #DebugDirectX flags     set(CMAKE_CXX_FLAGS_DEBUGDIRECTX "/D_DEBUG 
/MDd /Zi /Ob0 /Od /RTC1" CACHE STRING "Flags used by the C++ compiler during 
maintainer builds." FORCE)      set(CMAKE_C_FLAGS_DEBUGDIRECTX "/D_DEBUG /MDd 
/Zi  /Ob0 /Od /RTC1" CACHE STRING "Flags used by the C compiler during 
maintainer builds." FORCE) set(CMAKE_EXE_LINKER_FLAGS_DEBUGDIRECTX "/debug 
/INCREMENTAL" CACHE STRING "Flags used for linking binaries during maintainer 
builds." FORCE )  set(CMAKE_SHARED_LINKER_FLAGS_DEBUGDIRECTX "/debug 
/INCREMENTAL" CACHE STRING "Flags used by the shared libraries linker during 
maintainer builds." FORCE )             #ReleaseDirectx flags   
set(CMAKE_CXX_FLAGS_RELEASEDIRECTX "/MD /O2 /Ob2 /D NDEBUG" CACHE STRING "Flags 
used by the C++ compiler during maintainer builds." FORCE)      
set(CMAKE_C_FLAGS_RELEASEDIRECTX "/MD /O2 /Ob2 /D NDEBUG" CACHE STRING "Flags 
used by the C compiler during maintainer builds." FORCE)  
set(CMAKE_EXE_LINKER_FLAGS_RELEASEDIRECTX "/INCREMENTAL:NO" CACHE STRING "Flags 
used for linking binaries during maintainer builds." FORCE )    
set(CMAKE_SHARED_LINKER_FLAGS_RELEASEDIRECTX "/INCREMENTAL:NO" CACHE STRING 
"Flags used by the shared libraries linker during maintainer builds." FORCE 
)endif()
2.
I have been able to exclude .cpp files from the visual studio build by doing 
this:
set_source_files_properties(${files}PROPERTIES HEADER_FILE_ONLY true)
But in visual studio you can right click a file-> properties and select exclude 
file from build.. this sets a red icon on the file. I want to do this for 
sepereate configurations as in question 1.                                      
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to