I use CMake to generate a Visual Studio 2010 project and solution file. Actually I could set different settings, like warning level, incremental building flag ect. from CMake. But I can't set additional includes and libraries, listed in the VC++ Directory configuration tab. Actually I've to set up those directories manually. This is stupid and boring...
I tried to set the following CMake variables: CMAKE_INCLUDE_PATH, INCLUDE_DIRECTORY but nothing happend. If i open the project, the additional include directory of the solution is always empty (only standard MSVE settings are given).
I also tired to set this variables after executable creation, but this has also no effect.
This is what i do directly in the header of the cmake file:
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(${MODULE_NAME})
IF (MSVC)
# Activate C++ exception handling
IF (NOT CMAKE_CXX_FLAGS MATCHES "/EHsc")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
ENDIF ()
# Set Warning level always to 4
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
ELSE ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
ENDIF ()
#read path of dependency modules
file(READ "msvc.deps" MSVC_PROPERTIES)
STRING(REGEX REPLACE ";" "\\\\;" MSVC_PROPERTIES "${MSVC_PROPERTIES}")
STRING(REGEX REPLACE "\n" ";" MSVC_PROPERTIES "${MSVC_PROPERTIES}")
FOREACH(e ${MSVC_PROPERTIES})
SET(INCLUDE ${INCLUDE} ${e})
MESSAGE(STATUS "[INFO]: Value ${e}")
ENDFOREACH(e)
INCLUDE_DIRECTORIES(${INCLUDE})
ENDIF ()
In the .deps file I've added to path of my dependeny modules, line separated:
c:\binrev\development\boost\1.47\includes
c:\binrev\repository\modules\brCore\trunk\includes
Both are read successfully but couldn't be set as additional include directory in my MSVC solution.
Best regards, Hellhound
To add a library in CMake, use the add_library() command and specify which source files should make up the library. Rather than placing all of the source files in one directory, we can organize our project with one or more subdirectories. In this case, we will create a subdirectory specifically for our library.
Open the Command Palette (Ctrl+Shift+P) and run the CMake: Build command, or select the Build button from the Status bar. You can select which targets you'd like to build by selecting CMake: Set Build Target from the Command Palette. By default, CMake Tools builds all targets.
Load and run CMake code from a file or module. Loads and runs CMake code from the file given. Variable reads and writes access the scope of the caller (dynamic scoping).
CMake is pretty well documented, if I have understood your question then the commands I think you're looking for are
Although some configuration is done by setting variables, most of it is done using commands to add certain information to parts of the build and slightly less frequently by setting properties on targets.
I believe that include_directories ("path")
somewhere in the CMakeLists.txt does add the path
to C++ includes path.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With