-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
87 lines (74 loc) · 2.78 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
cmake_minimum_required(VERSION 3.21.1)
project(lilray)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
#if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# set(CMAKE_OSX_ARCHITECTURES x86_64)
# set(ONLY_ACTIVE_ARCH NO)
#endif()
set(CMAKE_CXX_FLAGS -DMINIFB_AVOID_CPP_HEADERS)
include(FetchContent)
FetchContent_Declare(minifb GIT_REPOSITORY https://github.com/badlogic/minifb GIT_TAG dos-pr)
set(MINIFB_BUILD_EXAMPLES CACHE INTERNAL FALSE)
FetchContent_MakeAvailable(minifb)
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize=undefined")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=undefined")
include_directories(src)
if (EMSCRIPTEN)
add_executable(liblilray "src/lilray.cpp" "src/lilray-c.cpp")
target_link_options(liblilray PRIVATE
"-sSTRICT=1"
"-sENVIRONMENT=web"
"-sLLD_REPORT_UNDEFINED"
"-sMODULARIZE=1"
"-sALLOW_MEMORY_GROWTH=1"
"-sALLOW_TABLE_GROWTH"
"-sMALLOC=emmalloc"
"-sEXPORT_ALL=1"
"-sEXPORTED_FUNCTIONS=[\"_malloc\",\"_free\"]"
"-sASYNCIFY"
"--no-entry"
"-sEXPORT_NAME=liblilray"
)
endif()
add_executable(lilray "src/lilray.cpp" "src/main.cpp")
target_link_libraries(lilray LINK_PUBLIC minifb)
add_executable(lilray_c "src/lilray.cpp" "src/lilray-c.cpp" "src/main.c")
target_link_libraries(lilray_c LINK_PUBLIC minifb)
add_executable(subpixel "src/subpixel.cpp" "src/lilray.cpp")
target_link_libraries(subpixel LINK_PUBLIC minifb)
add_custom_target(assets
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/assets
$<TARGET_FILE_DIR:lilray>/assets
)
add_custom_target(web_assets
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/web
$<TARGET_FILE_DIR:lilray>
)
get_property(targets DIRECTORY "${_dir}" PROPERTY BUILDSYSTEM_TARGETS)
list(REMOVE_ITEM targets minifb liblilray assets web_assets)
foreach(target IN LISTS targets)
target_link_libraries(${target} LINK_PUBLIC minifb)
add_dependencies(${target} assets)
if(EMSCRIPTEN)
add_dependencies(${target} web_assets)
target_link_options(${target} PRIVATE
"-sSTRICT=1"
"-sENVIRONMENT=web"
"-sLLD_REPORT_UNDEFINED"
"-sMODULARIZE=1"
"-sALLOW_MEMORY_GROWTH=1"
"-sALLOW_TABLE_GROWTH"
"-sMALLOC=emmalloc"
"-sEXPORT_ALL=1"
"-sEXPORTED_FUNCTIONS=[\"_malloc\",\"_free\",\"_main\"]"
"-sASYNCIFY"
"--no-entry"
"-sEXPORT_NAME=${target}"
)
endif()
endforeach()