File: CMakeLists.txt

package info (click to toggle)
cmake 4.2.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 152,456 kB
  • sloc: ansic: 403,896; cpp: 303,920; sh: 4,105; python: 3,583; yacc: 3,106; lex: 1,279; f90: 538; asm: 471; lisp: 375; cs: 270; java: 266; fortran: 239; objc: 215; perl: 213; xml: 198; makefile: 111; javascript: 83; pascal: 63; tcl: 55; php: 25; ruby: 22
file content (61 lines) | stat: -rw-r--r-- 2,175 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
cmake_minimum_required(VERSION 3.10)
project(VSExternalInclude)

# make sure directories exists
set(LIB1_BINARY_DIR ${VSExternalInclude_BINARY_DIR}/Lib1)
make_directory("${LIB1_BINARY_DIR}")

set(LIB2_BINARY_DIR ${VSExternalInclude_BINARY_DIR}/Lib2)
make_directory("${LIB2_BINARY_DIR}")

# generate lib1
execute_process(
  COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}"
    -A "${CMAKE_GENERATOR_PLATFORM}"
    -T "${CMAKE_GENERATOR_TOOLSET}" "${VSExternalInclude_SOURCE_DIR}/Lib1"
  WORKING_DIRECTORY ${LIB1_BINARY_DIR}
  OUTPUT_VARIABLE OUT
  ERROR_VARIABLE OUT
  )
message("CMAKE Ran with the following output:\n\"${OUT}\"")

# generate lib2
execute_process(
  COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}"
    -A "${CMAKE_GENERATOR_PLATFORM}"
    -T "${CMAKE_GENERATOR_TOOLSET}" "${VSExternalInclude_SOURCE_DIR}/Lib2"
  WORKING_DIRECTORY ${LIB2_BINARY_DIR}
  OUTPUT_VARIABLE OUT
  ERROR_VARIABLE OUT
  )
message("CMAKE Ran with the following output:\n\"${OUT}\"")


include_external_msproject(lib1 ${VSExternalInclude_BINARY_DIR}/Lib1/LIB1.vcxproj)
# lib2 depends on lib1
include_external_msproject(lib2 ${VSExternalInclude_BINARY_DIR}/Lib2/LIB2.vcxproj lib1)

include_directories(${VSExternalInclude_SOURCE_DIR}/Lib2 ${VSExternalInclude_SOURCE_DIR}/Lib1)

set(SOURCES main.cpp)

add_executable(VSExternalInclude ${SOURCES})

# target depends on lib2
add_dependencies(VSExternalInclude lib2)
# VS 10 vcxproj files have depends in them
# Since lib1 and lib2 do not depend on each other
# then the vcxproj files do not depend on each other
# and the sln file can no longer be the only source
# of that depend.  So, for VS 10 make the executable
# depend on lib1 and lib2
add_dependencies(VSExternalInclude lib1)

# Interaction testing between the FOLDER target property and
# INCLUDE_EXTERNAL_MSPROJECT targets:
set_target_properties(VSExternalInclude PROPERTIES FOLDER folder1/folder2)
set_target_properties(lib1 PROPERTIES FOLDER folder1/folder2)
set_target_properties(lib2 PROPERTIES FOLDER folder1/folder2)
add_custom_target(EmptyCustomTarget)
set_target_properties(EmptyCustomTarget PROPERTIES FOLDER folder1/folder2)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)