[CMake] VisualStudio 7.1 projects

Dekeyser, Kris Kris.Dekeyser at lms.be
Fri Sep 24 04:27:30 EDT 2004


Hi,

I'm a VS 6 user myself, but I think I can answer a couple of your questions
nevertheless.

- The answer may depend on what you want to achieve. The output directory is
what you specify as LIBRARY_OUTPUT_PATH and EXECUTABLE_OUTPUT_PATH.
CMake/MsDev puts the build type dir after it to allows for multiple build
types to coexist. If that's not ok for you, you can always move or copy the
generated target in a POST_BUILD ADD_CUSTOM_COMMAND. But make sure the next
targets to build can still find the targets it depends on.

- Yes, we had the exactly the same problem. For link libraries, CMake
provides the debug/optimized option to TARGET_LINK_LIBRARIES and that works
fine. Unfortunately there is no such option for LINK_DIRECTORIES and
INCLUDE_DIRECTORIES. You can solve the LINK_DIRECTORIES problem by adding
the full path to the library name in TARGET_LINK_LIBRARIES. I could not find
any way to solve the INCLUDE_DIRECTORIES problem than to create single-build
MsDev projects. I have added a FAQ for this to the CMake Wiki pages. It's
for VS6 and requires some effort. For VS7 it should be as easy as setting
the CMAKE_CONFIGURATION_TYPES to a single value(Debug/Release/...). This
means that you will have a separate build tree for each single configuration
type - exactly like what you would do with Makefile based builds.

- You can access environment variables with $ENV{varname}

- ADD_DEPENDENCIES should only be used for exceptions. Use
TARGET_LINK_LIBRARIES instead.

Best regards, Kris.

> -----Original Message-----
> From: Bojan Resnik [mailto:resnikb at swissinfo.org]
> Sent: Thursday, September 23, 2004 22:17
> To: cmake at www.cmake.org
> Subject: [CMake] VisualStudio 7.1 projects
> 
> 
>    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)
> 
> 
> _______________________________________________
> CMake mailing list
> CMake at www.cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
> 
+-+-+- Email Confidentiality Footer +-+-+- 
Privileged/Confidential Information may be contained in this message. If you
are not the addressee indicated in this message (or responsible for delivery
of the message to such person), you may not print, retain, copy nor
disseminate this message or any part of it to anyone and you should notify
the sender by reply email and destroy this message. Neglecting this clause
could be a breach of confidence. Please advise immediately if you or your
employer does not consent to Internet email for messages of this kind.
Opinions, conclusions and other information in this message that are not
related to the official business of my firm shall be understood as neither
given nor endorsed by it.



More information about the CMake mailing list