forked from OpenXcom/OpenXcom
-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
134 lines (120 loc) · 5.03 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
project ( OpenXcom )
cmake_minimum_required ( VERSION 2.8 )
set ( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules" )
option ( DEV_BUILD "Development Build. Disable this for release builds" ON )
option ( BUILD_PACKAGE "Prepares build for creation of a package with CPack" ON )
option ( ENABLE_WARNING "Always show warnings (even for release builds)" OFF )
option ( FATAL_WARNING "Treat warnings as errors" OFF )
option ( ENABLE_CLANG_ANALYSIS "When building with clang, enable the static analyzer" OFF )
set ( MSVC_WARNING_LEVEL 3 CACHE STRING "Visual Studio warning levels" )
option ( FORCE_INSTALL_DATA_TO_BIN "Force installation of data to binary directory" OFF )
set ( DATADIR "" CACHE STRING "Where to place datafiles" )
if ( WIN32 )
set ( default_deps_dir "${CMAKE_SOURCE_DIR}/deps" )
endif ()
if ( APPLE )
set ( MACOS_SDLMAIN_M_PATH "${CMAKE_SOURCE_DIR}" CACHE STRING "Path to SDLMain.m file" )
option ( CREATE_BUNDLE "Create a Mac OS application bundle" ON )
if ( NOT EXISTS "${MACOS_SDLMAIN_M_PATH}" )
message ( FATAL_ERROR "On Mac OS, SDLMain.m is required. Please set the MACOS_SDLMAIN_M_PATH variable" )
endif ()
endif ()
set ( DEPS_DIR "${default_deps_dir}" CACHE STRING "Dependencies directory" )
# Add check for library (SDL_gfx, yaml-cpp )
if ( IS_DIRECTORY ${DEPS_DIR} )
include_directories ( ${DEPS_DIR}/include/SDL ${DEPS_DIR}/include/yaml-cpp ${DEPS_DIR}/include )
if ( CMAKE_CL_64 )
link_directories ( ${DEPS_DIR}/lib/x64 )
else ( )
link_directories ( ${DEPS_DIR}/lib/Win32 )
endif()
set( SDL_LIBRARY SDL2 )
set ( SDLMIXER_LIBRARY SDL_mixer )
set ( SDLIMAGE_LIBRARY SDL_image )
set ( YAMLCPP_LIBRARY yaml-cpp )
else ( )
find_package ( SDL2 REQUIRED mixer image )
find_package ( SDL_gfx REQUIRED )
find_package ( Yaml_cpp 0.5.0)
find_package ( OpenGL )
if ( NOT OPENGL_FOUND )
message ( FATAL_ERROR "Can't find OpenGL; how does that even happen?" )
else ()
include_directories ( ${OPENGL_INCLUDE_DIR} )
endif ()
if ( NOT SDL2_FOUND )
message ( FATAL_ERROR "Can't find SDL which is required" )
else ()
include_directories ( ${SDL2_INCLUDE_DIRS} )
message ( "found SDL2 ${SDL_MAJOR}.${SDL_MINOR}.${SDL_MICRO} (${SDL2_LIBRARIES}:${SDL2_INCLUDE_DIRS})" )
endif ()
if ( NOT SDLGFX_FOUND )
message ( FATAL_ERROR "Can't find SDL_gfx which is required" )
else ()
include_directories ( ${SDLGFX_INCLUDE_DIR} )
message ( "found SDL_gfx(${SDLGFX_LIBRARY}:${SDLGFX_INCLUDE_DIR})" )
endif ()
if ( NOT YAMLCPP_FOUND )
message ( FATAL_ERROR "Can't find yaml-cpp which is required" )
else ()
include_directories ( ${YAMLCPP_INCLUDE_DIR} )
message ( "found yaml-cpp(${YAMLCPP_LIBRARY_DIRS}:${YAMLCPP_INCLUDE_DIR})" )
endif ( NOT YAMLCPP_FOUND )
endif()
# Read version number
set ( file "${CMAKE_SOURCE_DIR}/src/version.h" )
file ( READ ${file} lines )
string ( REGEX MATCH "[.]*OPENXCOM_VERSION_SHORT \"([0-9]).([0-9])" version_line "${lines}" )
set ( CPACK_PACKAGE_VERSION_MAJOR ${CMAKE_MATCH_1} )
set ( CPACK_PACKAGE_VERSION_MINOR ${CMAKE_MATCH_2} )
set ( CPACK_PACKAGE_VERSION_PATCH "" )
find_package ( Git )
if ( GIT_FOUND )
message("git found: ${GIT_EXECUTABLE}")
execute_process ( COMMAND ${GIT_EXECUTABLE} describe --dirty
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE git_describe_out
ERROR_VARIABLE git_describe_error
RESULT_VARIABLE git_describe_result
)
string ( REGEX MATCH "([a-z|0-9|.]*)-([0-9]*)-([a-z|0-9]*)([-|a-z]*)" git_commit "${git_describe_out}" )
set ( git_tag ${CMAKE_MATCH_1} )
set ( git_nb_commit ${CMAKE_MATCH_2} )
set ( git_commit ${CMAKE_MATCH_3} )
set ( git_dirty ${CMAKE_MATCH_4} )
add_definitions( -DOPENXCOM_VERSION_GIT="${git_commit}" )
endif()
if ( DEV_BUILD )
# Append the commit to version number
set ( CPACK_PACKAGE_VERSION_PATCH "${git_commit}${git_dirty}" )
set ( CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}" )
else ()
set ( CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_NSIS_PACKAGE_NAME}" )
set ( CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}" )
endif ()
if ( BUILD_PACKAGE )
if ( NOT DEV_BUILD )
string ( LENGTH "${git_dirty}" is_dirty )
if ( ${is_dirty} GREATER 0 )
message ( FATAL_ERROR "Release package must be built from a clean tree" )
endif ()
if ( "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" )
message ( FATAL_ERROR "Release package can't be built from a debug build" )
endif ()
endif ( )
set ( CPACK_PACKAGE_VENDOR "The OpenXcom project" )
set ( CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.txt" )
if ( NOT APPLE )
set ( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE.txt" )
endif ()
set ( CPACK_PACKAGE_CONTACT "The OpenXcom project (http://www.openxcom.org)" )
include ( deb )
include ( rpm )
include ( nsis )
include ( apple )
include ( CPack )
message ( "version:${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}"
)
endif()
add_subdirectory ( docs )
add_subdirectory ( src )