File tree 14 files changed +247
-2
lines changed
14 files changed +247
-2
lines changed Original file line number Diff line number Diff line change 1
- cmake_minimum_required (VERSION 3.3 )
1
+ cmake_minimum_required (VERSION 3.13 )
2
2
3
3
include (cmake/version .cmake)
4
4
@@ -49,6 +49,8 @@ option(BUILD_NO_OPTIMIZATION "Build without optimizations for debugging" OFF)
49
49
option (BUILD_ASAN_DEBUG "Build with AddressSanitizer" OFF )
50
50
option (BUILD_WITH_ZLIB "Build with zlib linked" ON )
51
51
option (TIC80_TARGET "Target binary suffix" )
52
+ option (PREFER_SYSTEM_LIBRARIES "Prefer link with system libraries" OFF )
53
+
52
54
53
55
if (NOT TIC80_TARGET)
54
56
set (TIC80_TARGET tic80)
@@ -69,6 +71,7 @@ endif()
69
71
70
72
target_compile_definitions (runtime INTERFACE BUILD_DEPRECATED)
71
73
74
+ message ("PREFER_SYSTEM_LIBRARIES: ${PREFER_SYSTEM_LIBRARIES} " )
72
75
message ("BUILD_STATIC: ${BUILD_STATIC} " )
73
76
message ("BUILD_SDLGPU: ${BUILD_SDLGPU} " )
74
77
message ("BUILD_TOUCH_INPUT: ${BUILD_TOUCH_INPUT} " )
Original file line number Diff line number Diff line change 2
2
# ArgParse lib
3
3
################################
4
4
5
+ if (PREFER_SYSTEM_LIBRARIES)
6
+ find_path (argparse_INCLUDE_DIR NAMES argparse.h)
7
+ find_library (argparse_LIBRARY NAMES argparse)
8
+ if (argparse_INCLUDE_DIR AND argparse_LIBRARY)
9
+ add_library (argparse UNKNOWN IMPORTED GLOBAL )
10
+ set_target_properties (argparse PROPERTIES
11
+ IMPORTED_LOCATION "${argparse_LIBRARY} "
12
+ INTERFACE_INCLUDE_DIRECTORIES "${argparse_INCLUDE_DIR} "
13
+ )
14
+ message (STATUS "Use system library: argparse" )
15
+ return ()
16
+ else ()
17
+ message (WARNING "System library argparse not found" )
18
+ endif ()
19
+ endif ()
20
+
5
21
add_library (argparse STATIC ${THIRDPARTY_DIR} /argparse/argparse.c)
6
22
target_include_directories (argparse INTERFACE ${THIRDPARTY_DIR} /argparse)
Original file line number Diff line number Diff line change 2
2
# GIFLIB
3
3
################################
4
4
5
+ if (PREFER_SYSTEM_LIBRARIES)
6
+ find_path (giflib_INCLUDE_DIR NAMES gif_lib.h)
7
+ find_library (giflib_LIBRARY NAMES gif)
8
+ if (giflib_INCLUDE_DIR AND giflib_LIBRARY)
9
+ add_library (giflib UNKNOWN IMPORTED GLOBAL )
10
+ set_target_properties (giflib PROPERTIES
11
+ IMPORTED_LOCATION "${giflib_LIBRARY} "
12
+ INTERFACE_INCLUDE_DIRECTORIES "${giflib_INCLUDE_DIR} ;${THIRDPARTY_DIR} /msf_gif"
13
+ )
14
+ message (STATUS "Use system library: giflib" )
15
+ return ()
16
+ else ()
17
+ message (WARNING "System library giflib not found" )
18
+ endif ()
19
+ endif ()
20
+
5
21
set (GIFLIB_DIR ${THIRDPARTY_DIR} /giflib)
6
22
set (GIFLIB_SRC
7
23
${GIFLIB_DIR} /dgif_lib.c
Original file line number Diff line number Diff line change 5
5
option (BUILD_WITH_JANET "Janet Enabled" ${BUILD_WITH_ALL} )
6
6
message ("BUILD_WITH_JANET: ${BUILD_WITH_JANET} " )
7
7
8
+ if (BUILD_WITH_JANET AND PREFER_SYSTEM_LIBRARIES)
9
+ find_path (janet_INCLUDE_DIR NAMES janet.h)
10
+ find_library (janet_LIBRARY NAMES janet)
11
+ if (janet_INCLUDE_DIR AND janet_LIBRARY)
12
+ add_library (janet STATIC
13
+ ${CMAKE_SOURCE_DIR} /src/api/janet.c
14
+ ${CMAKE_SOURCE_DIR} /src/api/parse_note.c
15
+ )
16
+ target_compile_definitions (janet INTERFACE TIC_BUILD_WITH_JANET)
17
+ target_link_libraries (janet PRIVATE runtime ${janet_LIBRARY} )
18
+ target_include_directories (janet
19
+ PUBLIC ${janet_INCLUDE_DIR}
20
+ PRIVATE
21
+ ${CMAKE_SOURCE_DIR} /include
22
+ ${CMAKE_SOURCE_DIR} /src
23
+ )
24
+ message (STATUS "Use sytem library: janet" )
25
+ return ()
26
+ else ()
27
+ message (WARNING "System library janet not found" )
28
+ endif ()
29
+ endif ()
30
+
8
31
if (BUILD_WITH_JANET)
9
32
10
33
if (MINGW)
Original file line number Diff line number Diff line change 5
5
option (BUILD_WITH_LUA "Lua Enabled" ON )
6
6
message ("BUILD_WITH_LUA: ${BUILD_WITH_LUA} " )
7
7
8
+ if (BUILD_WITH_LUA AND PREFER_SYSTEM_LIBRARIES)
9
+ find_path (lua_INCLUDE_DIR NAMES lua.h)
10
+ find_library (lua_LIBRARY NAMES lua)
11
+ if (lua_INCLUDE_DIR AND lua_LIBRARY)
12
+ add_library (luaapi STATIC
13
+ ${CMAKE_SOURCE_DIR} /src/api/luaapi.c
14
+ ${CMAKE_SOURCE_DIR} /src/api/parse_note.c
15
+ )
16
+ target_link_libraries (luaapi PRIVATE ${lua_LIBRARY} )
17
+ target_include_directories (luaapi PUBLIC
18
+ ${lua_INCLUDE_DIR}
19
+ ${CMAKE_SOURCE_DIR} /include
20
+ ${CMAKE_SOURCE_DIR} /src
21
+ )
22
+ add_library (lua STATIC ${CMAKE_SOURCE_DIR} /src/api/lua.c)
23
+ target_compile_definitions (lua INTERFACE TIC_BUILD_WITH_LUA)
24
+ target_link_libraries (lua PRIVATE runtime luaapi)
25
+ message (STATUS "Use system library: lua" )
26
+ return ()
27
+ else ()
28
+ message (WARNING "System library lua not found" )
29
+ endif ()
30
+ endif ()
31
+
8
32
if (BUILD_WITH_LUA OR BUILD_WITH_MOON OR BUILD_WITH_FENNEL)
9
33
set (LUA_DIR ${THIRDPARTY_DIR} /lua)
10
34
set (LUA_SRC
Original file line number Diff line number Diff line change 5
5
option (BUILD_WITH_RUBY "Ruby Enabled" ${BUILD_WITH_ALL} )
6
6
message ("BUILD_WITH_RUBY: ${BUILD_WITH_RUBY} " )
7
7
8
+ if (BUILD_WITH_RUBY AND PREFER_SYSTEM_LIBRARIES)
9
+ find_path (mruby_INCLUDE_DIR NAMES mruby.h)
10
+ find_library (mruby_LIBRARY NAMES mruby)
11
+ if (mruby_INCLUDE_DIR AND mruby_LIBRARY)
12
+ add_library (ruby STATIC
13
+ ${CMAKE_SOURCE_DIR} /src/api/mruby.c
14
+ ${CMAKE_SOURCE_DIR} /src/api/parse_note.c
15
+ )
16
+ target_compile_definitions (ruby INTERFACE TIC_BUILD_WITH_RUBY)
17
+ target_link_libraries (ruby PRIVATE runtime ${mruby_LIBRARY} )
18
+ target_include_directories (ruby
19
+ PUBLIC ${mruby_INCLUDE_DIR}
20
+ PRIVATE
21
+ ${CMAKE_SOURCE_DIR} /include
22
+ ${CMAKE_SOURCE_DIR} /src
23
+ )
24
+ message (STATUS "Use sytem library: mruby" )
25
+ return ()
26
+ else ()
27
+ message (WARNING "System library mruby not found" )
28
+ endif ()
29
+ endif ()
30
+
8
31
if (BUILD_WITH_RUBY)
9
32
10
33
find_program (RUBY ruby)
Original file line number Diff line number Diff line change @@ -14,6 +14,23 @@ if(LINUX)
14
14
endif ()
15
15
endif ()
16
16
17
+ if (PREFER_SYSTEM_LIBRARIES)
18
+ find_path (naett_INCLUDE_DIR NAMES naett.h)
19
+ find_library (naett_LIBRARY NAMES naett)
20
+ if (naett_INCLUDE_DIR AND naett_LIBRARY)
21
+ add_library (naett UNKNOWN IMPORTED GLOBAL )
22
+ set_target_properties (naett PROPERTIES
23
+ IMPORTED_LOCATION "${naett_LIBRARY} "
24
+ INTERFACE_INCLUDE_DIRECTORIES "${naett_INCLUDE_DIR} "
25
+ )
26
+ message (STATUS "Use system library: naett" )
27
+ set (USE_NAETT TRUE )
28
+ return ()
29
+ else ()
30
+ message (WARNING "System library naett not found" )
31
+ endif ()
32
+ endif ()
33
+
17
34
if (USE_NAETT)
18
35
add_library (naett STATIC ${THIRDPARTY_DIR} /naett/naett.c)
19
36
target_include_directories (naett PUBLIC ${THIRDPARTY_DIR} /naett)
Original file line number Diff line number Diff line change 2
2
# PNG
3
3
################################
4
4
5
+ if (PREFER_SYSTEM_LIBRARIES)
6
+ find_package (PkgConfig)
7
+ pkg_check_modules(libpng IMPORTED_TARGET GLOBAL libpng)
8
+ if (libpng_FOUND)
9
+ add_library (png ALIAS PkgConfig::libpng)
10
+ message (STATUS "Use system library: libpng" )
11
+ return ()
12
+ else ()
13
+ message (WARNING "System library libpng not found" )
14
+ endif ()
15
+ endif ()
16
+
17
+
5
18
set (LIBPNG_DIR ${THIRDPARTY_DIR} /libpng)
6
19
set (LIBPNG_SRC
7
20
${LIBPNG_DIR} /png.c
Original file line number Diff line number Diff line change 5
5
option (BUILD_WITH_JS "JS Enabled" ${BUILD_WITH_ALL} )
6
6
message ("BUILD_WITH_JS: ${BUILD_WITH_JS} " )
7
7
8
+ if (BUILD_WITH_JS AND PREFER_SYSTEM_LIBRARIES)
9
+ find_path (quickjs_INLCUDE_DIR NAMES quickjs.h PATH_SUFFIXES quickjs)
10
+ find_library (quickjs_LIBRARY NAMES quickjs PATH_SUFFIXES quickjs)
11
+ if (quickjs_INLCUDE_DIR AND quickjs_LIBRARY)
12
+ add_library (js STATIC
13
+ ${CMAKE_SOURCE_DIR} /src/api/js.c
14
+ ${CMAKE_SOURCE_DIR} /src/api/parse_note.c
15
+ )
16
+ target_compile_definitions (js INTERFACE TIC_BUILD_WITH_JS)
17
+ target_link_libraries (js PRIVATE runtime ${quickjs_LIBRARY} )
18
+ target_include_directories (js
19
+ PUBLIC ${quickjs_INLCUDE_DIR}
20
+ PRIVATE
21
+ ${CMAKE_SOURCE_DIR} /include
22
+ ${CMAKE_SOURCE_DIR} /src
23
+ )
24
+ message (STATUS "Use system library: quickjs" )
25
+ return ()
26
+ else ()
27
+ message (WARNING "System library quickjs not found" )
28
+ endif ()
29
+ endif ()
30
+
8
31
if (BUILD_WITH_JS)
9
32
10
33
set (QUICKJS_DIR ${THIRDPARTY_DIR} /quickjs)
Original file line number Diff line number Diff line change 1
1
################################
2
2
# SDL2
3
3
################################
4
- if (BUILD_SDL AND NOT EMSCRIPTEN AND NOT RPI)
4
+ if (PREFER_SYSTEM_LIBRARIES)
5
+ find_package (SDL2)
6
+ if (SDL2_FOUND)
7
+ add_library (SDL2 ALIAS SDL2::SDL2)
8
+ add_library (SDL2-static ALIAS SDL2::SDL2)
9
+ message (STATUS "Use system library: SDL2" )
10
+ else ()
11
+ message (WARNING "System library SDL2 not found" )
12
+ endif ()
13
+ endif ()
14
+
15
+
16
+ if (BUILD_SDL AND NOT EMSCRIPTEN AND NOT RPI AND NOT PREFER_SYSTEM_LIBRARIES)
5
17
6
18
if (WIN32 )
7
19
set (HAVE_LIBC TRUE )
Original file line number Diff line number Diff line change 5
5
option (BUILD_WITH_SQUIRREL "Squirrel Enabled" ${BUILD_WITH_ALL} )
6
6
message ("BUILD_WITH_SQUIRREL: ${BUILD_WITH_SQUIRREL} " )
7
7
8
+ if (BUILD_WITH_SQUIRREL AND PREFER_SYSTEM_LIBRARIES)
9
+ find_path (squirrel_INLCUDE_DIR NAMES squirrel.h PATH_SUFFIXES squirrel)
10
+ find_library (squirrel_LIBRARY NAMES squirrel)
11
+ find_library (sqstdlib_LIBRARY NAMES sqstdlib)
12
+ if (squirrel_INLCUDE_DIR AND squirrel_LIBRARY AND sqstdlib_LIBRARY)
13
+ add_library (squirrel STATIC
14
+ ${CMAKE_SOURCE_DIR} /src/api/squirrel.c
15
+ ${CMAKE_SOURCE_DIR} /src/api/parse_note.c
16
+ )
17
+ target_compile_definitions (squirrel INTERFACE TIC_BUILD_WITH_SQUIRREL)
18
+ target_link_libraries (squirrel PRIVATE runtime ${squirrel_LIBRARY} ${sqstdlib_LIBRARY} )
19
+ target_include_directories (squirrel
20
+ PUBLIC ${squirrel_INLCUDE_DIR}
21
+ PRIVATE
22
+ ${CMAKE_SOURCE_DIR} /include
23
+ ${CMAKE_SOURCE_DIR} /src
24
+ )
25
+ message (STATUS "Use system library: squirrel" )
26
+ return ()
27
+ else ()
28
+ message (WARNING "System library squirrel not found" )
29
+ endif ()
30
+ endif ()
31
+
32
+
8
33
if (BUILD_WITH_SQUIRREL)
9
34
10
35
set (SQUIRREL_DIR ${THIRDPARTY_DIR} /squirrel)
Original file line number Diff line number Diff line change 5
5
option (BUILD_WITH_WASM "Wasm Enabled" ${BUILD_WITH_ALL} )
6
6
message ("BUILD_WITH_WASM: ${BUILD_WITH_WASM} " )
7
7
8
+ if (BUILD_WITH_WASM AND PREFER_SYSTEM_LIBRARIES)
9
+ find_path (wasm_INCLUDE_DIR NAMES wasm3.h)
10
+ find_library (wasm_LIBRARY NAMES m3)
11
+ if (wasm_INCLUDE_DIR AND wasm_LIBRARY)
12
+ add_library (wasm STATIC
13
+ ${CMAKE_SOURCE_DIR} /src/api/wasm.c
14
+ )
15
+ target_compile_definitions (wasm INTERFACE TIC_BUILD_WITH_WASM)
16
+ target_link_libraries (wasm PRIVATE runtime ${wasm_LIBRARY} )
17
+ target_include_directories (wasm
18
+ PUBLIC ${wasm_INCLUDE_DIR}
19
+ PRIVATE
20
+ ${CMAKE_SOURCE_DIR} /include
21
+ ${CMAKE_SOURCE_DIR} /src
22
+ )
23
+ message (STATUS "Use system library: wasm" )
24
+ return ()
25
+ else ()
26
+ message (WARNING "System library wasm not found" )
27
+ endif ()
28
+ endif ()
29
+
8
30
if (BUILD_WITH_WASM)
9
31
10
32
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Dd_m3LogOutput=0" )
Original file line number Diff line number Diff line change 2
2
# ZIP
3
3
################################
4
4
5
+ if (PREFER_SYSTEM_LIBRARIES)
6
+ find_path (zip_INCLUDE_DIR NAMES zip.h PATH_SUFFIXES zip)
7
+ find_library (zip_LIBRARY NAMES zip)
8
+ if (zip_INCLUDE_DIR AND zip_LIBRARY)
9
+ add_library (zip UNKNOWN IMPORTED GLOBAL )
10
+ set_target_properties (zip PROPERTIES
11
+ IMPORTED_LOCATION "${zip_LIBRARY} "
12
+ INTERFACE_INCLUDE_DIRECTORIES "${zip_INCLUDE_DIR} "
13
+ )
14
+ message (STATUS "Use system library: kubazip" )
15
+ return ()
16
+ else ()
17
+ message (WARNING "System library kubazip not found" )
18
+ endif ()
19
+ endif ()
20
+
5
21
set (CMAKE_DISABLE_TESTING ON CACHE BOOL "" FORCE)
6
22
add_subdirectory (${THIRDPARTY_DIR} /zip)
Original file line number Diff line number Diff line change 2
2
# ZLIB
3
3
################################
4
4
5
+ if (PREFER_SYSTEM_LIBRARIES)
6
+ find_package (PkgConfig)
7
+ pkg_check_modules(zlib IMPORTED_TARGET GLOBAL zlib)
8
+ if (zlib_FOUND)
9
+ add_library (zlib ALIAS PkgConfig::zlib)
10
+ message (STATUS "Use system library: zlib" )
11
+ return ()
12
+ else ()
13
+ message (WARNING "System library zlib not found" )
14
+ endif ()
15
+ endif ()
16
+
5
17
if (NOT NINTENDO_3DS)
6
18
7
19
set (ZLIB_DIR ${THIRDPARTY_DIR} /zlib)
You can’t perform that action at this time.
0 commit comments