-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
66 lines (56 loc) · 2.21 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
cmake_minimum_required(VERSION 3.13)
project(curvedetect)
set(CMAKE_CXX_STANDARD 11)
# build resources
find_package( PythonInterp 3.0 REQUIRED )
set(RES_GEN_COMMAND ${PYTHON_EXECUTABLE}
${PROJECT_SOURCE_DIR}/libs/resource-builder/resource-builder.py #path to python script that builds resources
${PROJECT_SOURCE_DIR}/res #work directory where resources are stored
)
execute_process(COMMAND ${RES_GEN_COMMAND})
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
add_subdirectory(libs/glfw)
include_directories(
${PROJECT_SOURCE_DIR}/inc
${PROJECT_SOURCE_DIR}/res/build/include
${PROJECT_SOURCE_DIR}/libs/imgui
${PROJECT_SOURCE_DIR}/libs/portable-file-dialogs
${PROJECT_SOURCE_DIR}/libs/stb
${PROJECT_SOURCE_DIR}
)
file(GLOB all_SRCS
${PROJECT_SOURCE_DIR}/inc/*.h
${PROJECT_SOURCE_DIR}/inc/*.hpp
${PROJECT_SOURCE_DIR}/src/*.cpp
${PROJECT_SOURCE_DIR}/src/*.c
${PROJECT_SOURCE_DIR}/res/build/src/resources.cpp
${PROJECT_SOURCE_DIR}/glad/src/glad.c
${PROJECT_SOURCE_DIR}/libs/imgui/*.cpp
)
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
endif()
if( WIN32 )
add_executable(${PROJECT_NAME} ${all_SRCS}
${PROJECT_SOURCE_DIR}/res/win-res.rc
${PROJECT_SOURCE_DIR}/res/build/src/win.rc)
## On Windows disable console if not in debug mode
if( WIN32 AND NOT (CMAKE_BUILD_TYPE STREQUAL Debug) )
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static -mwindows")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set_target_properties(${PROJECT_NAME} PROPERTIES
LINK_FLAGS "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup"
)
endif()
endif()
else()
add_executable(${PROJECT_NAME} ${all_SRCS})
# link object files created by resource builder
file(GLOB all_OBJS ${PROJECT_SOURCE_DIR}/res/build/objs/*.o)
target_link_libraries(${PROJECT_NAME} ${all_OBJS})
endif()
target_link_libraries(${PROJECT_NAME} glfw)