forked from CedricGuillemet/Imogen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
177 lines (147 loc) · 6.38 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
cmake_minimum_required (VERSION 3.6)
project (Imogen)
# Add project's cmake modules to path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/.)
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_CONFIGURATION_TYPES "Debug;Release;RelWithDebInfo" CACHE STRING "Configuration types" FORCE)
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
file(GLOB_RECURSE SRC_FILES
${CMAKE_SOURCE_DIR}/src/*.h
${CMAKE_SOURCE_DIR}/src/*.cpp
)
file(GLOB EXT_FILES
${CMAKE_SOURCE_DIR}/ext/*.h
${CMAKE_SOURCE_DIR}/ext/*.cpp
${CMAKE_SOURCE_DIR}/ext/gl3w/GL/*.c
${CMAKE_SOURCE_DIR}/ext/cmft/*.cpp
${CMAKE_SOURCE_DIR}/ext/cmft/common/*.cpp
${CMAKE_SOURCE_DIR}/ext/enkiTS-C-11/src/*.cpp
${CMAKE_SOURCE_DIR}/ext/NativeFileDialog/src/nfd_common.c
${CMAKE_SOURCE_DIR}/ext/Nvidia-SBVH/*.cpp
${CMAKE_SOURCE_DIR}/ext/SOIL/src/*.c
${CMAKE_SOURCE_DIR}/ext/GLSL_Pathtracer/*.cpp
)
if(WIN32)
set(NFD_FILES ${CMAKE_SOURCE_DIR}/ext/NativeFileDialog/src/nfd_win.cpp)
set(PLATFORM_LIBS "libtcc")
else()
set(NFD_FILES ${CMAKE_SOURCE_DIR}/ext/NativeFileDialog/src/nfd_gtk.c
)
# Use the package PkgConfig to detect GTK+ headers/library files
FIND_PACKAGE(PkgConfig REQUIRED)
PKG_CHECK_MODULES(GTK3 REQUIRED gtk+-3.0)
# Setup CMake to use GTK+, tell the compiler where to look for headers
# and to the linker where to look for libraries
INCLUDE_DIRECTORIES(${GTK3_INCLUDE_DIRS})
LINK_DIRECTORIES(${GTK3_LIBRARY_DIRS})
# Add other flags to the compiler
ADD_DEFINITIONS(${GTK3_CFLAGS_OTHER})
set(PLATFORM_LIBS dl pthread ${GTK3_LIBRARIES} libtcc.a)
endif()
set(FFMPEG_LIBS avcodec.lib avdevice.lib avfilter.lib avformat.lib avutil.lib swscale.lib swresample.lib postproc.lib)
set(PYTHON37_LIBS python3.lib python37.lib)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/ext
${CMAKE_CURRENT_SOURCE_DIR}/ext/SDL2-2.0.8/include
${CMAKE_CURRENT_SOURCE_DIR}/ext/gl3w
${CMAKE_CURRENT_SOURCE_DIR}/ext/tcc-0.9.27/
${CMAKE_CURRENT_SOURCE_DIR}/ext/NativeFileDialog/src/include/
${CMAKE_CURRENT_SOURCE_DIR}/ext/enkiTS-C-11/src/
${CMAKE_CURRENT_SOURCE_DIR}/ext/ffmpeg/include
${CMAKE_CURRENT_SOURCE_DIR}/ext/python37/include
${CMAKE_CURRENT_SOURCE_DIR}/ext/glm/
${CMAKE_CURRENT_SOURCE_DIR}/ext/SOIL/include
${CMAKE_CURRENT_SOURCE_DIR}/ext/Nvidia-SBVH
${CMAKE_CURRENT_SOURCE_DIR}/ext/GLSL_Pathtracer/
)
link_directories(
${CMAKE_CURRENT_SOURCE_DIR}/ext/SDL2-2.0.8/lib/x64
${CMAKE_CURRENT_SOURCE_DIR}/ext/tcc-0.9.27/libtcc
${CMAKE_CURRENT_SOURCE_DIR}/ext/ffmpeg/lib
${CMAKE_CURRENT_SOURCE_DIR}/ext/python37/libs
)
find_package(OpenGL)
#######################################################################################
set (USE_MSVC_RUNTIME_LIBRARY_DLL true)
IF (NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
#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_CXX_FLAGS_RETAIL)
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)
ENDIF (NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
set(SDL2_LIBS "SDL2" "SDL2main")
#######################################################################################
foreach(f ${SRC_FILES})
# Get the path of the file relative to ${DIRECTORY},
# then alter it (not compulsory)
file(RELATIVE_PATH SRCGR ${CMAKE_SOURCE_DIR} ${f})
set(SRCGR "Sources/${SRCGR}")
# Extract the folder, ie remove the filename part
string(REGEX REPLACE "(.*)(/[^/]*)$" "\\1" SRCGR ${SRCGR})
# Source_group expects \\ (double antislash), not / (slash)
string(REPLACE / \\ SRCGR ${SRCGR})
source_group("${SRCGR}" FILES ${f})
endforeach()
set(ENABLE_HIDECONSOLE_BUILD TRUE CACHE BOOL "TRUE to hide console for Windows sys")
if(WINDOWS)
set(GUI_TYPE WIN32)
elseif(MACOSX)
set(GUI_TYPE MACOSX_BUNDLE)
endif()
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
endif()
SET(LINK_OPTIONS " ")
SET(EXE_NAME "Imogen")
ADD_EXECUTABLE(${EXE_NAME} ${SRC_FILES} ${EXT_FILES} ${NFD_FILES})
TARGET_LINK_LIBRARIES(${EXE_NAME} ${SDL2_LIBS} ${OPENGL_LIBRARIES} ${PLATFORM_LIBS} ${FFMPEG_LIBS} ${PYTHON37_LIBS})
#--------------------------------------------------------------------
# preproc
#--------------------------------------------------------------------
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D__STDC_FORMAT_MACROS)
add_definitions(-DBX_CONFIG_ENABLE_MSVC_LEVEL4_WARNINGS=1)
add_definitions(-D__STDC_LIMIT_MACROS)
add_definitions(-D__STDC_CONSTANT_MACROS)
add_definitions(-DIMGUI_DISABLE_OBSOLETE_FUNCTIONS)
if(MSVC)
add_definitions(-DWIN32)
add_definitions(-D_WIN32)
add_definitions(-DNOMINMAX)
endif()
add_definitions(-DUSE_DL_PREFIX)
#--------------------------------------------------------------------
# output dirs
#--------------------------------------------------------------------
set_target_properties("Imogen" PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/bin )
set_target_properties("Imogen" PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/bin )
set_target_properties("Imogen" PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_SOURCE_DIR}/bin )
set_target_properties("Imogen" PROPERTIES DEBUG_POSTFIX "_d")
set_target_properties("Imogen" PROPERTIES RELWITHDEBINFO_POSTFIX "RelWithDebInfo")
set_target_properties("Imogen" PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
#--------------------------------------------------------------------
# Hide the console window in visual studio projects
#--------------------------------------------------------------------
if(ENABLE_HIDECONSOLE_BUILD)
if(MSVC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")
endif()
endif()
if(WINDOWS)
set_target_properties("Imogen" PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:WINDOWS")
set_target_properties("Imogen" PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")
endif()
if(ENABLE_HIDECONSOLE_BUILD)
MESSAGE(STATUS "Console is hidden")
else()
MESSAGE(STATUS "Console is visible")
endif()