1 cmake_minimum_required (VERSION 2.6)
2 PROJECT(VSExternalInclude)
4 IF(${CMAKE_GENERATOR} MATCHES "Visual Studio 6")
6 ELSE(${CMAKE_GENERATOR} MATCHES "Visual Studio 6")
7 SET(PROJECT_EXT vcproj)
8 ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio 6")
9 IF(${CMAKE_GENERATOR} MATCHES "Visual Studio 10")
10 SET(PROJECT_EXT vcxproj)
13 # make sure directories exists
14 SET(LIB1_BINARY_DIR ${VSExternalInclude_BINARY_DIR}/Lib1)
15 MAKE_DIRECTORY("${LIB1_BINARY_DIR}")
17 SET(LIB2_BINARY_DIR ${VSExternalInclude_BINARY_DIR}/Lib2)
18 MAKE_DIRECTORY("${LIB2_BINARY_DIR}")
21 EXEC_PROGRAM("${CMAKE_COMMAND}" "${LIB1_BINARY_DIR}" ARGS -G\"${CMAKE_GENERATOR}\"
22 \"${VSExternalInclude_SOURCE_DIR}/Lib1\" OUTPUT_VARIABLE OUT)
23 MESSAGE("CMAKE Ran with the following output:\n\"${OUT}\"")
26 EXEC_PROGRAM("${CMAKE_COMMAND}" "${LIB2_BINARY_DIR}" ARGS -G\"${CMAKE_GENERATOR}\"
27 \"${VSExternalInclude_SOURCE_DIR}/Lib2\" OUTPUT_VARIABLE OUT)
28 MESSAGE("CMAKE Ran with the following output:\n\"${OUT}\"")
31 INCLUDE_EXTERNAL_MSPROJECT(lib1 ${VSExternalInclude_BINARY_DIR}/Lib1/LIB1.${PROJECT_EXT})
32 # lib2 depends on lib1
33 INCLUDE_EXTERNAL_MSPROJECT(lib2 ${VSExternalInclude_BINARY_DIR}/Lib2/LIB2.${PROJECT_EXT} lib1)
35 INCLUDE_DIRECTORIES(${VSExternalInclude_SOURCE_DIR}/Lib2 ${VSExternalInclude_SOURCE_DIR}/Lib1)
39 ADD_EXECUTABLE(VSExternalInclude ${SOURCES})
41 # target depends on lib2
42 ADD_DEPENDENCIES(VSExternalInclude lib2)
43 # VS 10 vcxproj files have depends in them
44 # Since lib1 and lib2 do not depend on each other
45 # then the vcxproj files do not depend on each other
46 # and the sln file can no longer be the only source
47 # of that depend. So, for VS 10 make the executable
48 # depend on lib1 and lib2
50 ADD_DEPENDENCIES(VSExternalInclude lib1)