--- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,6 @@ string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE_UC) endif() -find_package(Git) if(Git_FOUND) execute_process( COMMAND ${GIT_EXECUTABLE} status @@ -159,47 +158,15 @@ # LUA ################################ -set(LUA_DIR ${THIRDPARTY_DIR}/lua) -set(LUA_SRC - ${LUA_DIR}/lapi.c - ${LUA_DIR}/lcode.c - ${LUA_DIR}/lctype.c - ${LUA_DIR}/ldebug.c - ${LUA_DIR}/ldo.c - ${LUA_DIR}/ldump.c - ${LUA_DIR}/lfunc.c - ${LUA_DIR}/lgc.c - ${LUA_DIR}/llex.c - ${LUA_DIR}/lmem.c - ${LUA_DIR}/lobject.c - ${LUA_DIR}/lopcodes.c - ${LUA_DIR}/lparser.c - ${LUA_DIR}/lstate.c - ${LUA_DIR}/lstring.c - ${LUA_DIR}/ltable.c - ${LUA_DIR}/ltm.c - ${LUA_DIR}/lundump.c - ${LUA_DIR}/lvm.c - ${LUA_DIR}/lzio.c - ${LUA_DIR}/lauxlib.c - ${LUA_DIR}/lbaselib.c - ${LUA_DIR}/lcorolib.c - ${LUA_DIR}/ldblib.c - ${LUA_DIR}/liolib.c - ${LUA_DIR}/lmathlib.c - ${LUA_DIR}/loslib.c - ${LUA_DIR}/lstrlib.c - ${LUA_DIR}/ltablib.c - ${LUA_DIR}/lutf8lib.c - ${LUA_DIR}/loadlib.c - ${LUA_DIR}/linit.c -) +# FIXME +find_package(PkgConfig) +pkg_check_modules(Lua REQUIRED lua5.3 IMPORTED_TARGET GLOBAL) +add_library(Lua::Lua ALIAS PkgConfig::Lua) +set(LUA_INCLUDE_DIR "/usr/include/lua5.3") +set(LUA_LIBRARIES "/usr/lib/lua5.3") +include_directories(${LUA_INCLUDE_DIR}) +link_directories(${LUA_LIBRARIES}) -add_library(lua STATIC ${LUA_SRC}) - -target_compile_definitions(lua PRIVATE LUA_COMPAT_5_2) -target_include_directories(lua INTERFACE ${THIRDPARTY_DIR}/lua) - if(N3DS) target_compile_definitions(lua PUBLIC LUA_32BITS) endif() @@ -374,20 +341,7 @@ # GIFLIB ################################ -set(GIFLIB_DIR ${THIRDPARTY_DIR}/giflib) -set(GIFLIB_SRC - ${GIFLIB_DIR}/dgif_lib.c - ${GIFLIB_DIR}/egif_lib.c - ${GIFLIB_DIR}/gif_err.c - ${GIFLIB_DIR}/gif_font.c - ${GIFLIB_DIR}/gif_hash.c - ${GIFLIB_DIR}/gifalloc.c - ${GIFLIB_DIR}/openbsd-reallocarray.c -) -add_library(giflib STATIC ${GIFLIB_SRC}) -target_include_directories(giflib - PRIVATE ${GIFLIB_DIR} - INTERFACE ${THIRDPARTY_DIR}/giflib) +find_package(GIF) ################################ # Blipbuf @@ -444,6 +398,7 @@ ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src) + target_link_libraries(tic80core${SCRIPT} lua lpeg @@ -452,7 +407,7 @@ squirrel duktape blipbuf - zlib + z ) if(BUILD_WITH_MRUBY) @@ -461,7 +416,7 @@ if(${BUILD_DEPRECATED}) target_compile_definitions(tic80core${SCRIPT} PRIVATE BUILD_DEPRECATED) - target_link_libraries(tic80core${SCRIPT} giflib) + target_link_libraries(tic80core${SCRIPT} gif) endif() if(LINUX) @@ -507,10 +462,10 @@ set(SDL_STATIC_PIC ON CACHE BOOL "" FORCE) endif() - set(SDL_SHARED OFF CACHE BOOL "" FORCE) + find_package(SDL2) + set(SDL2_INCLUDE_DIR "/usr/include/SDL2") + include_directories(${SDL2_INCLUDE_DIR}) - add_subdirectory(${THIRDPARTY_DIR}/sdl2) - endif() ################################ @@ -531,7 +486,7 @@ target_link_options(player-sdl PRIVATE -static) endif() - target_link_libraries(player-sdl tic80core SDL2-static SDL2main) + target_link_libraries(player-sdl tic80core SDL2 SDL2main) endif() ################################ @@ -659,30 +614,8 @@ if (NOT N3DS) -set(ZLIB_DIR ${THIRDPARTY_DIR}/zlib) -set(ZLIB_SRC - ${ZLIB_DIR}/adler32.c - ${ZLIB_DIR}/compress.c - ${ZLIB_DIR}/crc32.c - ${ZLIB_DIR}/deflate.c - ${ZLIB_DIR}/inflate.c - ${ZLIB_DIR}/infback.c - ${ZLIB_DIR}/inftrees.c - ${ZLIB_DIR}/inffast.c - ${ZLIB_DIR}/trees.c - ${ZLIB_DIR}/uncompr.c - ${ZLIB_DIR}/zutil.c -) +find_package(ZLIB) -add_library(zlib STATIC ${ZLIB_SRC}) -target_include_directories(zlib INTERFACE ${THIRDPARTY_DIR}/zlib) - -else () - -add_library(zlib STATIC IMPORTED) -set_target_properties( zlib PROPERTIES IMPORTED_LOCATION ${DEVKITPRO}/portlibs/3ds/lib/libz.a ) -target_include_directories(zlib INTERFACE ${DEVKITPRO}/portlibs/3ds/include) - endif () ################################ @@ -713,7 +646,7 @@ target_link_libraries(wasmp2cart tic80core) add_executable(bin2txt ${TOOLS_DIR}/bin2txt.c) - target_link_libraries(bin2txt zlib) + target_link_libraries(bin2txt z) add_executable(xplode ${TOOLS_DIR}/xplode.c @@ -722,7 +655,7 @@ ${CMAKE_SOURCE_DIR}/src/studio/project.c) target_include_directories(xplode PRIVATE ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/include) - target_link_libraries(xplode tic80core png giflib) + target_link_libraries(xplode tic80core png gif) if(LINUX) target_link_libraries(xplode m) @@ -804,7 +737,8 @@ ################################ if(USE_LIBUV) - add_subdirectory(${THIRDPARTY_DIR}/libuv) + pkg_check_modules(libuv REQUIRED libuv IMPORTED_TARGET GLOBAL) + add_library(libuv:libuv ALIAS PkgConfig::libuv) endif() ################################ @@ -812,44 +746,16 @@ ################################ if(USE_LIBUV) - add_library(http_parser STATIC ${THIRDPARTY_DIR}/http-parser/http_parser.c) - target_include_directories(http_parser INTERFACE ${THIRDPARTY_DIR}/http-parser) + set(HTTP_PARSER_INCLUDE_DIR "/usr/include") + set(HTTP_PARSER_LIBRARIES "/usr/lib/libhttp_parser.so") endif() ################################ # PNG ################################ -set(LIBPNG_DIR ${THIRDPARTY_DIR}/libpng) -set(LIBPNG_SRC - ${LIBPNG_DIR}/png.c - ${LIBPNG_DIR}/pngerror.c - ${LIBPNG_DIR}/pngget.c - ${LIBPNG_DIR}/pngmem.c - ${LIBPNG_DIR}/pngpread.c - ${LIBPNG_DIR}/pngread.c - ${LIBPNG_DIR}/pngrio.c - ${LIBPNG_DIR}/pngrtran.c - ${LIBPNG_DIR}/pngrutil.c - ${LIBPNG_DIR}/pngset.c - ${LIBPNG_DIR}/pngtrans.c - ${LIBPNG_DIR}/pngwio.c - ${LIBPNG_DIR}/pngwrite.c - ${LIBPNG_DIR}/pngwtran.c - ${LIBPNG_DIR}/pngwutil.c -) +find_package(PNG) -configure_file(${LIBPNG_DIR}/scripts/pnglibconf.h.prebuilt ${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h) - -add_library(png STATIC ${LIBPNG_SRC}) - -target_compile_definitions(png PRIVATE PNG_ARM_NEON_OPT=0) - -target_include_directories(png - PUBLIC ${CMAKE_CURRENT_BINARY_DIR} - PRIVATE ${THIRDPARTY_DIR}/zlib - INTERFACE ${THIRDPARTY_DIR}/libpng) - ################################ # TIC-80 studio ################################ @@ -896,11 +802,11 @@ target_include_directories(tic80studio PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) -target_link_libraries(tic80studio tic80core zip wave_writer argparse giflib png) +target_link_libraries(tic80studio tic80core zip wave_writer argparse gif png) if(USE_LIBUV) target_compile_definitions(tic80studio PRIVATE USE_LIBUV) - target_link_libraries(tic80studio uv_a http_parser) + target_link_libraries(tic80studio uv http_parser) endif() if(BUILD_PRO) @@ -982,7 +888,7 @@ endif() if(NOT EMSCRIPTEN) - target_link_libraries(sdlgpu SDL2-static) + target_link_libraries(sdlgpu SDL2) endif() endif() @@ -1050,7 +956,7 @@ elseif(RPI) target_link_libraries(tic80 libSDL2.a bcm_host) else() - target_link_libraries(tic80 SDL2-static) + target_link_libraries(tic80 SDL2) endif() endif() @@ -1199,7 +1105,7 @@ elseif(RPI) target_link_libraries(tic80${SCRIPT} libSDL2.a bcm_host pthread dl) else() - target_link_libraries(tic80${SCRIPT} SDL2-static) + target_link_libraries(tic80${SCRIPT} SDL2) endif() endif()