forked from kongaskristjan/PhaseTransition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
51 lines (38 loc) · 1.62 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
cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_STANDARD 14)
project(PhaseTransition)
#add_compile_options("-pg")
#add_link_options("-pg")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
if(NOT EMSCRIPTEN)
find_package(Threads REQUIRED)
find_package(SDL2 REQUIRED)
find_package(SDL2TTF REQUIRED)
endif()
find_package(SDL2Image)
if(SDLIMAGE_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D SDL2_IMAGE_ENABLED")
endif()
FILE(GLOB LibSources Lib/*.cpp Lib/*.h)
add_library(library ${LibSources})
FILE(GLOB RunSources PhaseTransition/*.cpp PhaseTransition/*.h)
add_executable(PhaseTransition ${RunSources})
if(EMSCRIPTEN)
include_directories(.)
target_link_libraries(PhaseTransition --bind library)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s USE_SDL=2 -s USE_SDL_TTF=2 -s ASSERTIONS=1 -s ALLOW_MEMORY_GROWTH=1")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --embed-file ${CMAKE_SOURCE_DIR}/Setups@PhaseTransition")
configure_file(PhaseTransition/PhaseTransition.html PhaseTransition.html COPY_ONLY)
else()
include_directories(${SDL2_INCLUDE_DIRS} ${SDL2TTF_INCLUDE_DIR} ${SDL2_IMAGE_INCLUDE_DIR} .)
target_link_libraries(PhaseTransition library ${SDL2_LIBRARIES} ${SDL2TTF_LIBRARY} ${SDL2_IMAGE_LIBRARY} Threads::Threads)
endif()
# Testing
find_package(GTest)
if(GTest_FOUND)
FILE(GLOB TestSources Tests/*.cpp)
add_executable(RunTests ${TestSources})
target_link_libraries(RunTests library ${SDL2_LIBRARIES} ${SDL2TTF_LIBRARY} Threads::Threads GTest::GTest GTest::Main)
gtest_discover_tests(RunTests)
add_test(NAME monolithic COMMAND RunTests)
endif()