forked from HiGuyMB/Dif
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
122 lines (104 loc) · 4.3 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
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
include (CheckIncludeFiles)
project (Dif C CXX)
# Allow C++11 features
if (UNIX)
list (APPEND CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
elseif(MSVC)
list (APPEND CMAKE_CXX_FLAGS "/MP ${CMAKE_CXX_FLAGS}")
endif()
# Enable Static Linking the C++ ABI directly into the executables and libraries
if (MSVC)
#---BEGIN COPY FROM BULLET CMAKE---
#We statically link to reduce dependancies
FOREACH(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO )
IF(${flag_var} MATCHES "/MD")
STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
ENDIF(${flag_var} MATCHES "/MD")
IF(${flag_var} MATCHES "/MDd")
STRING(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}")
ENDIF(${flag_var} MATCHES "/MDd")
ENDFOREACH(flag_var)
#---END COPY FROM BULLET CMAKE---
endif()
# http://stackoverflow.com/a/7750816
# Basically just force the output dir to where we give
macro(target_output_directory targetname directory)
set_target_properties( ${targetname} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${directory} )
set_target_properties( ${targetname} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${directory} )
set_target_properties( ${targetname} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${directory} )
# Second, for multi-config builds (e.g. msvc)
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
set_target_properties( ${targetname} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${directory} )
set_target_properties( ${targetname} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${directory} )
set_target_properties( ${targetname} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${directory} )
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
endmacro()
set (DIF_SRC
############################################################################
# Sources
############################################################################
# Base
src/dif/base/io.cpp
# Objects
src/dif/objects/aiSpecialNode.cpp
src/dif/objects/dif.cpp
src/dif/objects/forceField.cpp
src/dif/objects/gameEntity.cpp
src/dif/objects/interior.cpp
src/dif/objects/interiorPathFollower.cpp
src/dif/objects/staticMesh.cpp
src/dif/objects/trigger.cpp
src/dif/objects/vehicleCollision.cpp
############################################################################
# Headers
############################################################################
# Base
include/dif/base/color.h
include/dif/base/io.h
include/dif/base/types.h
# Objects
include/dif/objects/aiSpecialNode.h
include/dif/objects/dif.h
include/dif/objects/forceField.h
include/dif/objects/gameEntity.h
include/dif/objects/interior.h
include/dif/objects/interiorPathFollower.h
include/dif/objects/staticMesh.h
include/dif/objects/trigger.h
include/dif/objects/vehicleCollision.h
)
# Create the library
add_library(Dif STATIC ${DIF_SRC})
include_directories(include)
include_directories(3rdparty/glm)
# create CAPI DLL
set (C_API_SRC
src/difAPI.cpp
include/difAPI.h
)
add_library(DifPlugin SHARED ${C_API_SRC})
target_link_libraries(DifPlugin Dif)
# Stop OSX from putting "lib" in front of the name
set_target_properties(DifPlugin PROPERTIES PREFIX "")
# Plugin suffix should be .bundle on OSX, .dll on Windows
if (APPLE)
set_target_properties(DifPlugin PROPERTIES SUFFIX ".bundle")
elseif (MSVC)
set_target_properties(DifPlugin PROPERTIES SUFFIX ".dll")
endif()
###############################################################################
# Tests
###############################################################################
add_executable(DifTests tests/main.cpp)
target_link_libraries(DifTests Dif)
add_executable(dif2obj tests/dif2obj.cpp)
target_link_libraries(dif2obj Dif)
# Make it go to where we want. Default is the plugins directory but you can change
# this if you're not building as a submodule.
option (OUTPUT_DIRECTORY_CUSTOM "Use a custom output directory." OFF)
set (OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../Assets/Plugins/" CACHE PATH "Path where the built plugin will go")
if (OUTPUT_DIRECTORY_CUSTOM)
target_output_directory(DifPlugin "${OUTPUT_DIRECTORY}")
endif ()