-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
46 lines (37 loc) · 1.59 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
cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
function(update_git_submodules MSG_TYPE)
message(STATUS "Updating git submodules...")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
RESULT_VARIABLE UPDATE_SUBMODULES_RESULT
)
if(NOT UPDATE_SUBMODULES_RESULT EQUAL "0")
message(${MSG_TYPE} "git submodule update failed!")
endif()
endfunction()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "")
set(APP_VERSION "1.0.0" CACHE STRING "Application Version" FORCE)
project(pkmn VERSION ${APP_VERSION})
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
option(PKMN_GIT_UPDATE_SUBMODULES "Init/Update submodules during generation" ON)
if(PKMN_GIT_UPDATE_SUBMODULES)
update_git_submodules(FATAL_ERROR)
endif()
endif()
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.*pp")
# Libraries
add_subdirectory(libs/djson)
add_executable(${PROJECT_NAME} ${SOURCES})
target_include_directories(${PROJECT_NAME} PRIVATE libs/include)
if(CMAKE_CXX_COMPILER_ID STREQUAL Clang OR CMAKE_CXX_COMPILER_ID STREQUAL GNU)
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra $<$<NOT:$<CONFIG:Debug>>:-Werror>)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(${PROJECT_NAME} PRIVATE $<$<NOT:$<CONFIG:Debug>>:/WX>)
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME})
endif()
target_link_libraries(${PROJECT_NAME} PUBLIC djson::djson)