-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
105 lines (86 loc) · 2.51 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
cmake_minimum_required(VERSION 3.15)
project(juce_nanovg VERSION 1.0.0)
set(CMAKE_CXX_STANDARD 20)
if("${CMAKE_SYSTEM}" MATCHES "Linux")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-Bsymbolic")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-Symbolic")
endif()
# JUCE
add_subdirectory(Libraries/JUCE)
# nanovg
set(NANOVG_DIR Libraries/nanovg)
if(APPLE)
file(GLOB_RECURSE NANOVG_SRC
${NANOVG_DIR}/*.h
${NANOVG_DIR}/*.c
${NANOVG_DIR}/*.m
)
else()
file(GLOB_RECURSE NANOVG_SRC
${NANOVG_DIR}/*.h
${NANOVG_DIR}/*.c
)
endif()
add_library(nanovg STATIC ${NANOVG_SRC})
target_include_directories(nanovg PUBLIC ${NANOVG_DIR})
# enable automatic reference counting, needed for nvg_metal
if(APPLE)
set_property (TARGET nanovg APPEND_STRING PROPERTY
COMPILE_FLAGS "-fobjc-arc")
endif()
#-----------------------------------------------------------
set(TARGET "test_nanovg")
juce_add_gui_app(${TARGET}
PRODUCT_NAME "Test NanoVG"
VERSION "1.0.0"
COMPANY_NAME "Arthur Benilov and Timothy Schoen"
)
target_compile_definitions(${TARGET} PUBLIC JUCE_WEB_BROWSER=0 JUCE_USE_CURL=0 DONT_SET_USING_JUCE_NAMESPACE=1)
if(APPLE)
target_compile_definitions(${TARGET} PUBLIC NANOVG_GL2_IMPLEMENTATION)
target_compile_definitions(nanovg PUBLIC NANOVG_GL2_IMPLEMENTATION)
else()
target_compile_definitions(${TARGET} PUBLIC NANOVG_GLES2_IMPLEMENTATION)
target_compile_definitions(nanovg PUBLIC NANOVG_GLES2_IMPLEMENTATION)
endif()
target_link_libraries(${TARGET}
PRIVATE
juce::juce_core
juce::juce_data_structures
juce::juce_gui_basics
juce::juce_gui_extra
juce::juce_opengl
PUBLIC
juce::juce_recommended_config_flags
)
juce_generate_juce_header(${TARGET})
file(GLOB_RECURSE src
${CMAKE_CURRENT_SOURCE_DIR}/Source/*.h
${CMAKE_CURRENT_SOURCE_DIR}/Source/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Source/example/*.h
${CMAKE_CURRENT_SOURCE_DIR}/Source/example/*.cpp
)
target_sources(${TARGET} PRIVATE ${src})
file(GLOB_RECURSE res "${CMAKE_CURRENT_SOURCE_DIR}/Resources/*.*")
juce_add_binary_data(${TARGET}_res SOURCES ${res})
target_link_libraries(${TARGET} PUBLIC ${TARGET}_res)
target_compile_definitions(${TARGET}
PUBLIC
JUCE_DISPLAY_SPLASH_SCREEN=1
)
target_link_libraries(${TARGET}
PRIVATE
nanovg
)
if(APPLE)
target_link_libraries(${TARGET}
PRIVATE
"-framework Metal"
)
endif()
if("${CMAKE_SYSTEM}" MATCHES "Linux")
target_link_libraries(${TARGET}
PRIVATE
-lGL -lGLEW -lGLX
)
endif()