-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
64 lines (48 loc) · 2.11 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
cmake_minimum_required(VERSION 3.26)
project(Milang)
set(CMAKE_CXX_STANDARD 17)
option(BUILD_SHARED_LIBS "Build shared library" ON)
# ---------------------------------------------------------------------------------------
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# Windows DLLs are "runtime" for CMake. Output them to "bin" like the Visual Studio projects do.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# Reset output dirs for multi-config builds
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/lib)
endforeach(OUTPUTCONFIG)
if(BUILD_SHARED_LIBS)
set(MILANG_LIBRARY_PREFIX "${CMAKE_SHARED_LIBRARY_PREFIX}")
else()
set(MILANG_LIBRARY_PREFIX "${CMAKE_STATIC_LIBRARY_PREFIX}")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
# ---------------------------------------------------------------------------------------
set(MILANG_SRC)
set(MILANG_CXX_FLAGX)
if (APPLE)
set(MILANG_CXX_FLAGX "-framework Foundation")
set(MILANG_SRC ${MILANG_SRC} src/lib_apple.cpp)
elseif (WIN32)
set(MILANG_SRC ${MILANG_SRC} src/lib_windows.cpp)
else()
message(FATAL_ERROR "The platform is not supported.")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MILANG_CXX_FLAGX}")
add_library(Milang ${MILANG_SRC})
target_include_directories(Milang
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)
# Add compile definitions. MILIZE_DLL is visible to all targets in the project such as MilangMainApp.
if(BUILD_SHARED_LIBS)
target_compile_definitions(Milang PUBLIC MILIZE_DLL PRIVATE MILIZE_BUILDING_SHARED_LIBS)
endif()
# ---------------------------------------------------------------------------------------
add_subdirectory(app)