forked from SamVanheer/HalfLifeAssetManager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
159 lines (133 loc) · 3.59 KB
/
CMakeLists.txt
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
###################################################
# #
# #
# Half-Life Tools CMake build file #
# #
# #
###################################################
cmake_minimum_required( VERSION 3.6 )
include( cmake/InputFilesList.cmake )
include( cmake/MSVCRuntime.cmake )
include( cmake/PDBUtils.cmake )
include( cmake/Ternary.cmake )
include( cmake/WinXPSupport.cmake )
macro( copy_dependencies project_name base_dir )
foreach( lib ${ARGN} )
add_custom_command( TARGET ${project_name} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${CMAKE_SOURCE_DIR}/${base_dir}/${lib}"
"$<TARGET_FILE_DIR:${project_name}>"
)
endforeach()
endmacro()
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin )
project( HL_Tools )
set( SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src )
if( UNIX )
set( LINUX_32BIT_FLAG "-m32" )
else()
set( LINUX_32BIT_FLAG "" )
endif()
#C++14 support
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y" )
#Hide symbols from static libraries so they don't merge and cause issues
if( UNIX )
if( CMAKE_COMPILER_IS_GNUCC )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--exclude-libs,ALL" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--exclude-libs,ALL" )
endif()
endif()
#Shared directories
#Save the shares sources into SHARED_SRCS
get_property(SHARED_SRCS GLOBAL PROPERTY SRCS_LIST)
clear_sources()
#Shared preprocessor definitions
#TODO: There's a file in CMake that can do this called TestBigEndian. See http://stackoverflow.com/questions/3877344/detect-endianness-with-cmake
#Consider using this
set( IS_LITTLE_ENDIAN_TARGET "1" CACHE BOOL "Whether the target system is little endian" )
#TODO really need to find a better way to do this
if( IS_LITTLE_ENDIAN_TARGET )
set( IS_LITTLE_ENDIAN_VALUE "1" )
else()
set( IS_LITTLE_ENDIAN_VALUE "0" )
endif()
if( WIN32 )
set( SHARED_DEFS
UNICODE
_UNICODE
_CRT_SECURE_NO_WARNINGS
_SCL_SECURE_NO_WARNINGS
)
else()
endif()
set( SHARED_DEFS
${SHARED_DEFS}
IS_LITTLE_ENDIAN=${IS_LITTLE_ENDIAN_VALUE}
)
if( WIN32 )
set( SHARED_WX_DEFS
${SHARED_DEFS}
)
else()
set( SHARED_WX_DEFS
_FILE_OFFSET_BITS=64
WXUSINGDLL
__WXGTK__
${SHARED_DEFS}
)
endif()
#Shared include dirs
set( SHARED_INCLUDEPATHS
"${CMAKE_CURRENT_SOURCE_DIR}/src/stdlib"
"${CMAKE_CURRENT_SOURCE_DIR}/src/engine"
"${CMAKE_CURRENT_SOURCE_DIR}/src/core"
"${CMAKE_CURRENT_SOURCE_DIR}/src"
"${CMAKE_CURRENT_SOURCE_DIR}/external/GLEW/include"
"${CMAKE_CURRENT_SOURCE_DIR}/external/GLM/include"
)
#Find shared dependencies
if( WIN32 )
set( SHARED_DEPENDENCIES
)
else()
set( SHARED_DEPENDENCIES
dl
stdc++fs #C++17 experimental filesystem
)
endif()
#TODO shared compile flags
if( WIN32 )
set( SHARED_COMPILE_FLAGS
)
else()
set( SHARED_COMPILE_FLAGS
"${LINUX_32BIT_FLAG} -fPIC"
)
endif()
if( WIN32 )
set( WX_SHARED_COMPILE_FLAGS
${SHARED_COMPILE_FLAGS}
)
else()
set( WX_SHARED_COMPILE_FLAGS
${SHARED_COMPILE_FLAGS}
)
endif()
#Shared linker settings
if( WIN32 )
set( WX_LINKER_FLAGS "/SUBSYSTEM:WINDOWS" )
else()
set( WX_LINKER_FLAGS "" )
endif()
set( SHARED_LINK_FLAGS
"${LINUX_32BIT_FLAG}"
)
set( SHARED_WX_LINK_FLAGS
"${SHARED_LINK_FLAGS} ${WX_LINKER_FLAGS}"
)
#Include source code
add_subdirectory( src )