forked from brackeen/glfm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
64 lines (54 loc) · 2.8 KB
/
CMakeLists.txt
File metadata and controls
64 lines (54 loc) · 2.8 KB
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.1.0) # Cmake 3.18 required for Xcode 12
project(GLFM C)
option(GLFM_BUILD_EXAMPLE "Build the GLFM example" OFF)
set(GLFM_HEADERS include/glfm.h)
if (CMAKE_SYSTEM_NAME MATCHES "Emscripten")
set(GLFM_SRC src/glfm_platform.h src/glfm_platform_emscripten.c)
set(GLFM_COMPILE_FLAGS "-Wno-gnu-zero-variadic-macro-arguments")
elseif (CMAKE_SYSTEM_NAME MATCHES "Android")
set(GLFM_SRC src/glfm_platform.h src/glfm_platform_android.c ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c)
# Set NDEBUG for android_native_app_glue to remove some superfluous logging
set_source_files_properties(${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c PROPERTIES COMPILE_FLAGS "-DNDEBUG")
else() # Assume iOS
set(IOS TRUE)
if (${CMAKE_OSX_SYSROOT} MATCHES "(MacOS)+")
set(CMAKE_OSX_SYSROOT "iphoneos")
endif()
set(GLFM_SRC src/glfm_platform.h src/glfm_platform_ios.m)
set(GLFM_COMPILE_FLAGS "-Wno-objc-interface-ivars -Wno-objc-missing-property-synthesis -Wno-direct-ivar-access")
endif()
add_library(glfm ${GLFM_SRC} ${GLFM_HEADERS})
target_include_directories(glfm PUBLIC include)
target_include_directories(glfm PRIVATE src)
source_group(include FILES ${GLFM_HEADERS})
source_group(src FILES ${GLFM_SRC})
if (CMAKE_C_COMPILER_ID MATCHES "Clang")
set_target_properties(glfm PROPERTIES COMPILE_FLAGS "-Weverything -Wwrite-strings -Wno-padded -Wno-covered-switch-default -Wno-auto-import ${GLFM_COMPILE_FLAGS}")
elseif (CMAKE_C_COMPILER_ID MATCHES "GNU")
set_target_properties(glfm PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wwrite-strings ${GLFM_COMPILE_FLAGS}")
elseif (CMAKE_C_COMPILER_ID MATCHES "MSVC")
set_target_properties(glfm PROPERTIES COMPILE_FLAGS "/Wall ${GLFM_COMPILE_FLAGS}")
endif()
if (CMAKE_SYSTEM_NAME MATCHES "Android")
find_library(log-lib log)
find_library(android-lib android)
find_library(EGL-lib EGL)
find_library(GLESv2-lib GLESv2)
target_link_libraries(glfm ${log-lib} ${android-lib} ${EGL-lib} ${GLESv2-lib})
target_include_directories(glfm PRIVATE ${ANDROID_NDK}/sources/android/native_app_glue/)
set_target_properties(glfm PROPERTIES
C_STANDARD 99)
elseif (IOS)
target_compile_definitions(glfm PRIVATE GLES_SILENCE_DEPRECATION)
set_target_properties(glfm PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/GLFM.build/lib # For Archiving
XCODE_ATTRIBUTE_SUPPORTED_PLATFORMS "iphoneos iphonesimulator appletvos appletvsimulator"
XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET 9.0
XCODE_ATTRIBUTE_TVOS_DEPLOYMENT_TARGET 9.0
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES
XCODE_ATTRIBUTE_CLANG_ENABLE_MODULES YES # Automatically import frameworks
)
endif()
if (GLFM_BUILD_EXAMPLE)
add_subdirectory(example)
endif()