forked from ainvyu/vcxproj2cmake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.tx
88 lines (73 loc) · 2.83 KB
/
CMakeLists.tx
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
cmake_minimum_required(VERSION 2.8)
## section: Macro
MACRO(ADD_MSVC_PRECOMPILED_HEADER PrecompiledHeader PrecompiledSource SourcesVar)
IF(MSVC)
GET_FILENAME_COMPONENT(PrecompiledBasename ${PrecompiledHeader} NAME_WE)
SET(PrecompiledBinary "${CMAKE_CURRENT_BINARY_DIR}/${PrecompiledBasename}.pch")
SET(Sources ${${SourcesVar}})
SET_SOURCE_FILES_PROPERTIES(${PrecompiledSource}
PROPERTIES COMPILE_FLAGS "/Yc\"${PrecompiledHeader}\" /Fp\"${PrecompiledBinary}\""
OBJECT_OUTPUTS "${PrecompiledBinary}")
SET_SOURCE_FILES_PROPERTIES(${Sources}
PROPERTIES COMPILE_FLAGS "/Yu\"${PrecompiledBinary}\" /FI\"${PrecompiledBinary}\" /Fp\"${PrecompiledBinary}\""
OBJECT_DEPENDS "${PrecompiledBinary}")
# Add precompiled header to SourcesVar
LIST(APPEND ${SourcesVar} ${PrecompiledSource})
ENDIF(MSVC)
ENDMACRO(ADD_MSVC_PRECOMPILED_HEADER)
## start setting
SET (this_target [% $target %])
PROJECT(${this_target})
[% IF charset == 'Unicode' %]
add_definitions(-DUNICODE -D_UNICODE)
[% END %]
## section: include directory
INCLUDE_DIRECTORIES(
[% $include %]
)
## section: source files
# Add your source files here (one file per line), please SORT in alphabetical order for future maintenance
SET (${this_target}_SOURCE_FILES
[% $src %]
)
## section: header files
# Add your header files here(one file per line), please SORT in alphabetical order for future maintenance!
SET(${this_target}_HEADER_FILES
[% $header %]
)
[% source_groups %]
## section: precompiled header
#ADD_MSVC_PRECOMPILED_HEADER("precompiled.h" "precompiled.cpp" MySources)
#ADD_LIBRARY(MyLibrary ${MySources})
SET_SOURCE_FILES_PROPERTIES(${this_target}_HEADER_FILES
PROPERTIES HEADER_FILE_ONLY TRUE)
LIST(APPEND ${this_target}_SOURCE_FILES ${${this_target}_HEADER_FILES})
## section: add definitions
# add prefix -D. example> -DSHP
# - DO NOT add the following definitions(already defined in ${OSP_DEFINITIONS}:
# -DSHP, -DWIN32, -D_WINDOWS, -D_DEBUG, -D_USRDLL, -D_CRT_SECURE_NO_DEPRECATE
ADD_DEFINITIONS(
[% $def %]
)
## section: add target
[% SWITCH type %]
[% CASE 'Application' %]
ADD_EXECUTABLE(${this_target} ${${this_target}_SOURCE_FILES})
[% CASE 'DynamicLibrary' %]
ADD_LIBRARY(${this_target} SHARED ${${this_target}_SOURCE_FILES} )
[% CASE 'StaticLibrary' %]
ADD_LIBRARY(${this_target} STATIC ${${this_target}_SOURCE_FILES} )
[% CASE 'Module' %]
ADD_LIBRARY(${this_target} MODULE ${${this_target}_SOURCE_FILES} )
[% END %]
[%- IF lib -%]
## section: add dependency
# dependency determines overall build order.
ADD_DEPENDENCIES(${this_target}
[% $lib %]
)
## section: set link libraries
TARGET_LINK_LIBRARIES( ${this_target}
[% $lib %]
)
[%- END -%]