-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
105 lines (78 loc) · 3.42 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
### Initial CMake set-up
cmake_minimum_required(VERSION 3.12.4)
# Work around a bug with old MSVC
# if(${CMAKE_VERSION} VERSION_LESS 3.14)
# cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
# else()
# cmake_policy(VERSION 3.14)
# endif()
# if(NOT WIN32)
# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
# link_libraries(stdc++fs)
# endif()
# vcpkg setup
# set(VCPKG_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/external/vcpkg")
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
# Project definition
project(binviz VERSION 0.1 DESCRIPTION "BinViz")
if(NOT "${CMAKE_GENERATOR}" MATCHES "(Win64|IA64)" AND NOT VCPKG_TARGET_TRIPLET)
set(VCPKG_TARGET_TRIPLET "x64-windows")
endif()
# Global CMake options
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_MAP_IMPORTED_CONFIG_MINSIZEREL Release)
set(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO Release)
include_directories(src)
include_directories(external)
# if(MSVC)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /openmp")
# endif()
### Main executable
add_executable(${PROJECT_NAME} src/main.cpp)
### vcpkg dependencies
# spdlog
find_package(spdlog CONFIG REQUIRED)
# target_link_libraries(main PRIVATE spdlog::spdlog spdlog::spdlog_header_only)
target_compile_definitions(spdlog::spdlog INTERFACE SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE
SPDLOG_NO_THREAD_ID=1
SPDLOG_NO_DATETIME=1
SPDLOG_NO_NAME=1
SPDLOG_NO_ATOMIC_LEVELS=1
_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING
)
# imgui
find_package(imgui CONFIG REQUIRED)
# glm
find_package(glm CONFIG REQUIRED)
# glfw3
find_package(glfw3 CONFIG REQUIRED)
# glad
find_package(glad CONFIG REQUIRED)
# Dependency: nativefiledialog
find_package(unofficial-nativefiledialog CONFIG REQUIRED)
# OpenMP
find_package(OpenMP)
### Add source tree
add_subdirectory(src)
target_link_libraries(${PROJECT_NAME} PRIVATE
glad::glad glfw imgui::imgui glm::glm spdlog::spdlog imgui_glfw_gl3_backend stb_image util unofficial::nativefiledialog::nfd OpenMP::OpenMP_CXX)
### Add externals directory for additional externals
add_subdirectory(external)
set(SHADER_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/data/shaders/screen.vs.glsl
${CMAKE_CURRENT_SOURCE_DIR}/data/shaders/screen.fs.glsl)
set(SHADER_OUTPUTS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/data/shaders/screen.vs.glsl
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/data/shaders/screen.fs.glsl)
target_sources(${PROJECT_NAME} PRIVATE ${SHADER_OUTPUTS})
set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
# set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME})
add_custom_command(
OUTPUT ${SHADER_OUTPUTS}
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/data" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/data"
DEPENDS ${SHADER_SOURCES}
)