forked from playmer/bindbc-imgui
-
Notifications
You must be signed in to change notification settings - Fork 10
/
CMakeLists.txt
117 lines (98 loc) · 5.03 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
cmake_minimum_required(VERSION 3.16)
project(bindbc_imgui)
include(cmake/PullSubmodules.cmake)
PullSubmodules(${CMAKE_CURRENT_LIST_DIR}/.. submodulePrefixPath)
message(STATUS "submodulePrefixPath: ${submodulePrefixPath}")
####################
# Setup
set(CMAKE_DEBUG_POSTFIX "")
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
option(BUILD_SHARED_LIBS "Build shared instead of static libraries." ON)
set(PlatformArchitecture ${CMAKE_SYSTEM_PROCESSOR})
if(${CMAKE_GENERATOR} MATCHES "Visual Studio.*")
add_compile_options(/MP)
if (CMAKE_GENERATOR_PLATFORM)
if(${CMAKE_GENERATOR_PLATFORM} STREQUAL ARM64)
set(PlatformArchitecture arm64)
endif()
endif()
endif()
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(PlatformFolder "win32")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(PlatformFolder "darwin")
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
# This is neccesary to avoid macports/homebrew libraries to be seen
# these break universal builds.
set(CMAKE_IGNORE_PATH
/opt/local/lib
/opt/local/include
/opt/local/bin)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(PlatformFolder "linux")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Android")
set(PlatformFolder "android")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
set(PlatformFolder "bsd")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "MSYS")
set(PlatformFolder "win32")
else ()
set(PlatformFolder "Unknown")
endif()
set(OutputDirectory ${CMAKE_CURRENT_LIST_DIR}/../libs/${PlatformArchitecture}/${PlatformFolder})
if (DEFINED STATIC_CIMGUI)
set(OutputDirectory ${OutputDirectory}/Static)
set(IMGUI_STATIC "yes" CACHE STRING "Build as a static library")
else()
set(OutputDirectory ${OutputDirectory}/Dynamic)
set(IMGUI_STATIC "no" CACHE STRING "Build as a static library")
endif()
if (MSVC)
if(DEFINED WINDOWS_STATIC_CRT)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set(OutputDirectory ${OutputDirectory}/StaticCRT)
else()
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
set(OutputDirectory ${OutputDirectory}/DynamicCRT)
endif()
endif()
# Libraries are built for Mac/Windows, and consumed via the Package Manager for Linux
if (NOT UNIX OR APPLE OR DEFINED USE_SUBMODULE_SOURCES) # Windows and Mac
add_subdirectory(${freetype_SUBMOD_DIR})
set_target_properties(freetype PROPERTIES DEBUG_POSTFIX "")
set_target_properties(freetype PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${OutputDirectory})
set_target_properties(freetype PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${OutputDirectory})
set_target_properties(freetype PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${OutputDirectory})
set_target_properties(freetype PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${OutputDirectory})
set_target_properties(freetype PROPERTIES LIBRARY_OUTPUT_DIRECTORY_RELEASE ${OutputDirectory})
set_target_properties(freetype PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${OutputDirectory})
set(IMGUI_FREETYPE "yes" CACHE STRING "Build with freetype library")
set(IMGUI_FREETYPE_IN_TREE "yes" CACHE STRING "freetype library is being build in-tree")
add_subdirectory(${SDL_SUBMOD_DIR})
set_target_properties(SDL2 PROPERTIES DEBUG_POSTFIX "")
set_target_properties(SDL2 PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${OutputDirectory})
set_target_properties(SDL2 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${OutputDirectory})
set_target_properties(SDL2 PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${OutputDirectory})
set_target_properties(SDL2 PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${OutputDirectory})
set_target_properties(SDL2 PROPERTIES LIBRARY_OUTPUT_DIRECTORY_RELEASE ${OutputDirectory})
set_target_properties(SDL2 PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${OutputDirectory})
set(IMGUI_SDL_IN_TREE "yes" CACHE STRING "SDL library is built in-tree")
else() # Linux
include(FindFreetype)
#find_package(freetype MODULE REQUIRED)
set(IMGUI_FREETYPE "yes" CACHE STRING "Build with freetype library")
set(IMGUI_FREETYPE_IN_TREE "no" CACHE STRING "freetype library is being build in-tree")
find_package(SDL2 REQUIRED)
set(IMGUI_SDL_IN_TREE "no" CACHE STRING "SDL library is built in-tree")
endif()
option(BUILD_SHARED_LIBS "Build shared instead of static libraries." OFF)
set(IMGUI_SDL "yes" CACHE STRING "Build with SDL")
set(IMGUI_OPENGL3 "yes" CACHE STRING "Build with OpenGL3")
add_subdirectory(${cimgui_SUBMOD_DIR})
set_target_properties(cimgui PROPERTIES DEBUG_POSTFIX "")
set_target_properties(cimgui PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${OutputDirectory})
set_target_properties(cimgui PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${OutputDirectory})
set_target_properties(cimgui PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${OutputDirectory})
set_target_properties(cimgui PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${OutputDirectory})
set_target_properties(cimgui PROPERTIES LIBRARY_OUTPUT_DIRECTORY_RELEASE ${OutputDirectory})
set_target_properties(cimgui PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${OutputDirectory})