[CMake] How can I set different include_directories values for multiple C targets in a single CMakeLists.txt file?

Hickel, Kelly Kelly_Hickel at bmc.com
Tue Jun 1 16:34:40 EDT 2010


I'm trying to build two different versions of a library from a single CMakeLists.txt file (akin to what the FAQ section 7.1 spells out for building shared and static libraries).  However, the include_directories command doesn't accept a target the way that, for instance, target_link_libraries does (linking doesn't seem to be any problem at all).

I've tried using set_target_properties to set the COMPILE_FLAG property for each target to include the correct path, but that /I command doesn't appear in the project settings in Visual Studio (I'm starting on windows but will be branching out to other platforms eventually).

This is with CMake 2.8.1 on Windows 7 with VS 2005.

So, something like this, but I need to be able to build the v5 version with the v5 include path, not the v4 path.
cmake_minimum_required (VERSION 2.8)
project (test_with_ver_4)
project (test_with_ver_5)
add_library(test_with_ver_4 SHARED test.c )
add_library(test_with_ver_5 SHARED test.c )
include_directories ( "c:\\src\\pkg_v4\\include" )
target_link_libraries(test_with_ver_4 "c:\\src\\pkg_v4\\pkg_v4.lib")
target_link_libraries(test_with_ver_5 "c:\\src\\pkg_v5\\pkg_v5.lib")


Thanks in advance,
Kelly Hickel
BMC Software










More information about the CMake mailing list