-
Notifications
You must be signed in to change notification settings - Fork 13
/
CMakeLists.txt
45 lines (34 loc) · 1.61 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
cmake_minimum_required(VERSION 3.5)
project (NoobBoy)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
if( ${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};${EMSDK_PATH}/upstream/emscripten/cache/sysroot/lib/pkgconfig")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s USE_SDL=2 -s USE_FREETYPE=1 -s USE_SDL_MIXER=2 -s USE_SDL_TTF=2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${USE_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${USE_FLAGS} -s EXPORTED_RUNTIME_METHODS='[\"FS\",\"callMain\"]' -lembind")
else()
find_package(SDL2 REQUIRED)
find_package(SDL2_ttf REQUIRED)
find_package(SDL2_mixer REQUIRED)
find_package(Freetype REQUIRED)
endif()
include_directories(${SDL2_INCLUDE_DIRS})
include_directories(${SDL2_MIXER_INCLUDE_DIRS})
include_directories(${SDL2_TTF_INCLUDE_DIRS})
include_directories("/usr/local/include")
include_directories("/opt/homebrew/include")
include_directories("/opt/homebrew/lib")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
set (SOURCE_DIR "${PROJECT_SOURCE_DIR}/src/")
include_directories(${SOURCE_DIR})
link_directories(${SOURCE_DIR})
file (GLOB SOURCE_FILES "${SOURCE_DIR}/*.cpp")
list(FILTER SOURCE_FILES EXCLUDE REGEX "main(.*)\\.cpp")
if( ${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
set(MAIN_FILE "${SOURCE_DIR}/main_emscripten.cpp")
else ()
set(MAIN_FILE "${SOURCE_DIR}/main.cpp")
endif ()
list(APPEND SOURCE_FILES ${MAIN_FILE})
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} ${SDL2_LIBRARIES} ${SDL2_MIXER_LIBRARIES} ${SDL2_TTF_LIBRARIES})