[CMake] VisualStudio 7.1 projects

Bojan Resnik resnikb at swissinfo.org
Thu Sep 23 16:16:59 EDT 2004


   Hello all,

   I have installed the latest version of CMake and I am currently
trying to create my first CMakeLists.txt for an existing project of
mine. The project contains a shared library and a test executable.
I have come accross several problems I cannot solve:

   - How to set Output and Intermediate directories in generated
     VisualStudio projects? Currently, CMake always puts ./Debug for
     both of them.
     
   - How to set include directories, link directories, link libraries
     per project and per configuration? My project links to debug
     versions of third-party libraries in debug configuration, and to
     release version in the release configuration. Also, the test
     executable doesn't need the same definitions and include files as
     the shared library.

   - How to use the values of existing environment variables within
     CMakeLists.txt? The locations of third party libraries are
     defined by system environment variables. For now, I am wrapping
     them as in $(NAME), but this is MS specific. Can it be done in a
     portable way? 

   - The ADD_DEPENDENCIES command doesn't seem to work correctly. I
     have specified that my test executable depends on the shared
     library, but this is not reflected in the generated project
     files.
     
   Can all of this be done with CMake?
   
   Below is a stripped version of CMakeLists.txt file I am using,
with most shared library sources removed.

   Regards,
     Bojan Resnik

---- CMakeLists.txt -----
# Begin definition of this project
PROJECT(cb_sh C++)

# Define include directories
INCLUDE_DIRECTORIES(
        ../../..
        "$(ICU_DIR)/include"
        "$(BOOST_DIR)"
)

# Define library directories
LINK_DIRECTORIES(
        "$(BOOST_DIR)/lib"
)

IF (WIN32)
        LINK_DIRECTORIES(
                ${LINK_DIRECTORIES}
                "$(ICU_DIR)/lib/MSVC7.1/Debug"
        )
ENDIF (WIN32)

ADD_DEFINITIONS(-DCB_SH_EXPORTS)

# Define source file grouping
SOURCE_GROUP("Source Files" REGULAR_EXPRESSION [.]cpp$)
SOURCE_GROUP("Header Files" REGULAR_EXPRESSION [.]hpp$)

# Define source files
SET(FILES_SOURCE SharedSource.cpp)

# This will be built as a shared library
ADD_LIBRARY(cb_sh SHARED ${FILES_SOURCE})

# Add the test driver
ADD_EXECUTABLE(cb_sh_test TestMain.cpp)

# The following does not generate a dependency in MSVS project!
ADD_DEPENDENCIES(cb_sh_test cb_sh)




More information about the CMake mailing list