-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
65 lines (52 loc) · 2.16 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
cmake_minimum_required (VERSION 3.9)
project (gl_playground)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
include_directories(include)
include_directories(lib/include)
include(cmake/eigen.cmake.in)
include(cmake/glfw.cmake.in)
include(cmake/spdlog.cmake.in)
include(cmake/imgui.cmake.in)
include(cmake/entt.cmake.in)
include(cmake/libspng.cmake.in)
include(cmake/cxxopts.cmake.in)
set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR})
file(GLOB_RECURSE SOURCES src/*.cpp src/*.c lib/src/*.cpp lib/src/*.c)
add_executable(app ${SOURCES})
message(STATUS "Compiler: ${CMAKE_CXX_COMPILER_ID}")
target_compile_features(app PRIVATE cxx_std_20)
if(WIN32)
message(STATUS "Windows detected, adding compile flags")
target_compile_definitions(app PUBLIC
PLATFORM_WINDOWS
_USE_MATH_DEFINES
NOMINMAX
)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
message(STATUS "Clang detected, adding compile flags")
target_compile_options(app PRIVATE -Wall -Wno-c++98-compat -Wno-reserved-id-macro)
target_compile_features(app PRIVATE cxx_std_17)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
message(STATUS "GCC detected, adding compile flags")
target_compile_options(app PRIVATE -Wall)
target_compile_features(app PRIVATE cxx_std_17)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
message(STATUS "msvc detected, adding compile flags")
target_compile_options(app PRIVATE /std:c++20 /EHsc)
else()
message(STATUS "Could not determine compiler: ${CMAKE_CXX_COMPILER_ID}" )
target_compile_features(app PRIVATE cxx_std_17)
target_compile_options(app PRIVATE -Wall)
endif()
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "Debug build: adding compile flags")
target_compile_definitions(app PRIVATE BUILD_DEBUG)
elseif (CMAKE_BUILD_TYPE STREQUAL "Release")
message(STATUS "Release build: adding compile flags")
target_compile_definitions(app PRIVATE BUILD_RELEASE)
endif()
target_link_libraries(app glfw ${OPENGL_LIBRARIES} spdlog imgui EnTT spng cxxopts)