-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
135 lines (110 loc) · 4.26 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
cmake_minimum_required(VERSION 3.12)
project(CKImGui VERSION 0.3.0)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED NO)
set(CMAKE_CXX_EXTENSIONS YES)
# Add path for custom modules
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(GenerateExportHeader)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
if (NOT WIN32)
message(FATAL_ERROR "Only support Windows.")
endif ()
# Use relative paths
if (WIN32)
set(CMAKE_USE_RELATIVE_PATHS TRUE)
set(CMAKE_SUPPRESS_REGENERATION TRUE)
endif ()
# Use folders to organize targets in an IDE
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMakeTargets")
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as no build type was specified")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the build type (Debug/Release)" FORCE)
endif ()
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/install" CACHE PATH "The root directory of the installation" FORCE)
message(STATUS "Setting default install directory to ${CMAKE_INSTALL_PREFIX} as no install directory was specified")
endif ()
# Disable msvc unsafe warnings
if (MSVC)
add_compile_definitions(
$<$<C_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS>
$<$<C_COMPILER_ID:MSVC>:_CRT_NONSTDC_NO_WARNINGS>
)
endif ()
# Generate a CompilationDatabase (compile_commands.json)
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
find_package(VirtoolsSDK REQUIRED)
configure_file(${CMAKE_CURRENT_LIST_DIR}/ImGui.rc.in ${CMAKE_CURRENT_LIST_DIR}/ImGui.rc)
set(IMGUI_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/imgui)
set(IMGUI_HEADERS
${IMGUI_SOURCE_DIR}/imgui.h
${IMGUI_SOURCE_DIR}/imgui_internal.h
${IMGUI_SOURCE_DIR}/imstb_rectpack.h
${IMGUI_SOURCE_DIR}/imstb_textedit.h
${IMGUI_SOURCE_DIR}/imstb_truetype.h
${IMGUI_SOURCE_DIR}/backends/imgui_impl_win32.h
${CMAKE_CURRENT_SOURCE_DIR}/imgui_impl_ck2.h
)
set(IMGUI_SOURCES
${IMGUI_SOURCE_DIR}/imgui.cpp
${IMGUI_SOURCE_DIR}/imgui_draw.cpp
${IMGUI_SOURCE_DIR}/imgui_widgets.cpp
${IMGUI_SOURCE_DIR}/imgui_demo.cpp
${IMGUI_SOURCE_DIR}/imgui_tables.cpp
${IMGUI_SOURCE_DIR}/backends/imgui_impl_win32.cpp
${CMAKE_CURRENT_SOURCE_DIR}/imgui_impl_ck2.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ImGui.rc
)
add_library(ImGui SHARED)
target_sources(ImGui PRIVATE
Plugin.cpp
ImGuiManager.cpp
ImGuiManager.h
${IMGUI_SOURCES}
${IMGUI_HEADERS}
)
target_include_directories(ImGui PUBLIC
$<BUILD_INTERFACE:${IMGUI_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_link_libraries(ImGui PRIVATE CK2 VxMath)
target_compile_definitions(ImGui PRIVATE IMGUI_EXPORT)
add_custom_command(
TARGET ImGui PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/imconfig.h" "${IMGUI_SOURCE_DIR}"
VERBATIM
)
if (NOT SKIP_INSTALL_ALL)
configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/CMake/ImGuiConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/ImGuiConfig.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ImGui"
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/ImGuiConfigVersion.cmake"
COMPATIBILITY SameMinorVersion
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/ImGuiConfig.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ImGui"
)
install(TARGETS ImGui
EXPORT ImGuiTargets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(EXPORT ImGuiTargets
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ImGui")
if (NOT SKIP_INSTALL_HEADERS)
install(FILES
${IMGUI_SOURCE_DIR}/imconfig.h
${IMGUI_SOURCE_DIR}/imgui.h
${IMGUI_SOURCE_DIR}/imgui_internal.h
${IMGUI_SOURCE_DIR}/imstb_textedit.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
endif ()
endif ()