-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
88 lines (72 loc) · 3.78 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
CMAKE_MINIMUM_REQUIRED (VERSION 3.0.2)
project(TheLite2d)
SET (DEPENDENCIES_PATH ${PROJECT_SOURCE_DIR})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/cmake )
# FIND_PATH use CMKA_INCLUDE_PATH
set (CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} ${DEPENDENCIES_PATH}/SDL/include )
set (CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${DEPENDENCIES_PATH}/SDL/VisualC/Win32/Debug )
FIND_PACKAGE(SDL2 REQUIRED)
message("find SDL2 SDL2_INCLUDE_DIR = " ${SDL2_INCLUDE_DIR})
message("find SDL2 SDL2_LIBRARY = " ${SDL2_LIBRARY})
message("find SDL2 SDL2MAIN_LIBRARY = " ${SDL2MAIN_LIBRARY})
set (CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} ${DEPENDENCIES_PATH}/SDL2_image )
set (CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${DEPENDENCIES_PATH}/SDL2_image/VisualC/Win32/Debug )
FIND_PACKAGE(SDL2_image REQUIRED)
set (CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} ${DEPENDENCIES_PATH}/SDL2_ttf )
set (CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${DEPENDENCIES_PATH}/SDL2_ttf/VisualC/Win32/Debug )
FIND_PACKAGE(SDL2_ttf REQUIRED)
SET (SPDLOG_PATH ${DEPENDENCIES_PATH}/spdlog)
SET (SPDLOG_INCLUDE ${SPDLOG_PATH}/include)
SET (LIBRARY_THELITE2D_NAME TheLite2d)
set (THELITE2D_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/src/include )
set (SOURCES_PATH ${PROJECT_SOURCE_DIR}/src/)
file ( GLOB_RECURSE SRCS_ENGINE
"${THELITE2D_INCLUDE_DIR}/*.h"
"${SOURCES_PATH}/engine/*.cpp"
"${SOURCES_PATH}/engine/*.h"
)
IF ( WIN32 )
SET ( CMAKE_CXX_FLAGS_RELEASE " /O2 " CACHE STRING "Release Configuration" FORCE )
SET ( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /ZI /Od /D_DEV /D_LOG /W3 " CACHE STRING "Debug Configuration" FORCE )
SET ( VER_FILE 1.0.0 )
SET ( VER_PRODUCT 1.0 )
SET ( VER_INTERNAL_NAME "TheLite2d" )
# Trick to create structured folders on visual studio solution
set(_src_root_path "${SOURCES_PATH}")
foreach(_source IN ITEMS ${SRCS_GAME} ${SRCS_ENGINE} )
get_filename_component(_source_path "${_source}" PATH)
file(RELATIVE_PATH _source_path_rel "${_src_root_path}" "${_source_path}")
#set(_source_path_rel "${_source_path}" )
string(REPLACE "/" "\\" _group_path "${_source_path_rel}")
MESSAGE (" Group ${_group_path} ${_source}")
source_group("${_group_path}" FILES "${_source}")
endforeach()
ELSE ( WIN32 )
ADD_DEFINITIONS( -D_GCC -D_LINUX -D_MFC_THREAD_H -std=c++11)
SET ( CMAKE_CXX_FLAGS_DEBUG "-D_DEV -D_LOG -O0 -g")
SET ( CMAKE_CXX_FLAGS_RELEASE "-O0")
ENDIF ( WIN32 )
### Includes
include_directories(${THELITE2D_INCLUDE_DIR})
include_directories(${SDL2_INCLUDE_DIR})
include_directories(${SDL2_IMAGE_INCLUDE_DIR})
include_directories(${SPDLOG_INCLUDE})
include_directories(${SOURCES_PATH})
include_directories(${SDL2_TTF_INCLUDE_DIR})
### Outputs
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin/)
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/bin/debug/)
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/bin/release/)
SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin/)
SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/bin/debug/)
SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/bin/release/)
SET (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin/)
SET (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${PROJECT_SOURCE_DIR}/bin/debug/)
SET (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${PROJECT_SOURCE_DIR}/bin/release/)
#add_executable (${GAME_EXE} ${SRCS_ENGINE} ${SRCS_GAME} )
add_library(${LIBRARY_THELITE2D_NAME} STATIC ${SRCS_ENGINE})
SET_TARGET_PROPERTIES(${LIBRARY_THELITE2D_NAME} PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(${LIBRARY_THELITE2D_NAME} ${SDL2_LIBRARY} ${SDL2_IMAGE_LIBRARY} ${SDL2_TTF_LIBRARY} ${SDL2MAIN_LIBRARY} )
include(${CMAKE_CURRENT_SOURCE_DIR}/src/examples/CMakeLists.txt)
MESSAGE("Unit Testing")
include(${CMAKE_CURRENT_SOURCE_DIR}/src/test/CMakeLists.txt)