This repository has been archived by the owner on Jul 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
56 lines (43 loc) · 1.91 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
cmake_minimum_required(VERSION 3.19)
set(CMAKE_CXX_STANDARD 20)
project(EMLife)
if(BITS STREQUAL "x86")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
elseif(BITS STREQUAL "x64")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64")
endif()
set(EXECUTABLE_OUTPUT_PATH "${PROJECT_SOURCE_DIR}/dist")
if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "release")
#不显示dos窗口
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mwindows")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mwindows")
elseif(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "debug")
add_definitions(-DDEBUG)
message(STATUS "Add macro \"DEBUG\"")
endif()
find_package(SDL2 CONFIG REQUIRED)
find_package(sdl2-image CONFIG REQUIRED)
find_package(JsonCpp CONFIG REQUIRED)
find_package(unofficial-sqlite3 CONFIG REQUIRED)
include_directories("${PROJECT_SOURCE_DIR}/include")
file(GLOB_RECURSE SRC_FILE "${PROJECT_SOURCE_DIR}/src/*.cpp")
if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "release")
if(BITS STREQUAL "x86")
list(APPEND SRC_FILE "${PROJECT_SOURCE_DIR}/res/icon/build/icon-i386.o")
message(STATUS "Add icon \"icon-i386\"")
elseif(BITS STREQUAL "x64")
list(APPEND SRC_FILE "${PROJECT_SOURCE_DIR}/res/icon/build/icon-x86_64.o")
message(STATUS "Add icon \"icon-x86_64\"")
endif()
endif()
add_executable(${CMAKE_PROJECT_NAME} ${SRC_FILE})
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE SDL2::SDL2 SDL2::SDL2main SDL2::SDL2-static)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE SDL2::SDL2_image)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE jsoncpp_object jsoncpp_static JsonCpp::JsonCpp)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE unofficial::sqlite3::sqlite3)
execute_process(
COMMAND ${CMAKE_COMMAND} -E
copy_directory "${PROJECT_SOURCE_DIR}/res/assets" "${EXECUTABLE_OUTPUT_PATH}/assets"
)