TIC-80-guile/CMakeLists.txt

361 lines
9.3 KiB
CMake
Raw Normal View History

2018-05-18 15:58:33 +02:00
cmake_minimum_required(VERSION 3.9)
project(TIC-80 C)
message("Building for target : ${CMAKE_SYSTEM_NAME}")
2018-05-17 16:32:25 +02:00
2018-05-18 17:12:32 +02:00
if(UNIX AND NOT APPLE)
set(LINUX TRUE)
endif()
2018-05-17 16:32:25 +02:00
set(CMAKE_C_STANDARD 99)
2018-05-18 15:58:33 +02:00
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
2018-05-17 16:32:25 +02:00
################################
# LUA
################################
set(LUA_DIR 3rd-party/lua-5.3.1/src)
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}/lbitlib.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
)
add_library(lua STATIC ${LUA_SRC})
2018-05-21 12:58:38 +02:00
target_compile_definitions(lua PRIVATE LUA_COMPAT_5_2)
2018-05-17 16:32:25 +02:00
################################
# LPEG
################################
set(LPEG_DIR 3rd-party/lpeg-1.0.1)
set(LPEG_SRC
${LPEG_DIR}/lpcap.c
${LPEG_DIR}/lpcode.c
${LPEG_DIR}/lpprint.c
${LPEG_DIR}/lptree.c
${LPEG_DIR}/lpvm.c
)
add_library(lpeg STATIC ${LPEG_SRC})
target_include_directories(lpeg PRIVATE 3rd-party/lua-5.3.1/src)
################################
# WREN
################################
set(WREN_DIR 3rd-party/wren-0.1.0/src)
set(WREN_SRC
${WREN_DIR}/optional/wren_opt_meta.c
${WREN_DIR}/optional/wren_opt_random.c
${WREN_DIR}/vm/wren_compiler.c
${WREN_DIR}/vm/wren_core.c
${WREN_DIR}/vm/wren_debug.c
${WREN_DIR}/vm/wren_primitive.c
${WREN_DIR}/vm/wren_utils.c
${WREN_DIR}/vm/wren_value.c
${WREN_DIR}/vm/wren_vm.c
)
add_library(wren STATIC ${WREN_SRC})
target_include_directories(wren PRIVATE 3rd-party/wren-0.1.0/src/include)
target_include_directories(wren PRIVATE 3rd-party/wren-0.1.0/src/optional)
target_include_directories(wren PRIVATE 3rd-party/wren-0.1.0/src/vm)
################################
# GIFLIB
################################
set(GIFLIB_DIR 3rd-party/giflib-5.1.4/lib)
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})
################################
2018-05-18 13:56:45 +02:00
# TIC-80 core
2018-05-17 16:32:25 +02:00
################################
2018-05-18 13:56:45 +02:00
set(TIC80CORE_DIR src)
set(TIC80CORE_SRC
${TIC80CORE_DIR}/tic80.c
${TIC80CORE_DIR}/tic.c
${TIC80CORE_DIR}/tools.c
${TIC80CORE_DIR}/jsapi.c
${TIC80CORE_DIR}/luaapi.c
${TIC80CORE_DIR}/wrenapi.c
${TIC80CORE_DIR}/ext/gif.c
2018-05-17 22:39:56 +02:00
3rd-party/blip-buf/blip_buf.c # TODO: link it as lib?
3rd-party/duktape-2.2.0/src/duktape.c # TODO: link it as lib?
)
2018-05-18 13:56:45 +02:00
add_library(tic80core STATIC ${TIC80CORE_SRC})
2018-05-17 16:32:25 +02:00
2018-05-18 13:56:45 +02:00
target_include_directories(tic80core PRIVATE include)
target_include_directories(tic80core PRIVATE 3rd-party/blip-buf)
target_include_directories(tic80core PRIVATE 3rd-party/duktape-2.2.0/src)
target_include_directories(tic80core PRIVATE 3rd-party/lua-5.3.1/src)
target_include_directories(tic80core PRIVATE 3rd-party/giflib-5.1.4/lib)
target_include_directories(tic80core PRIVATE 3rd-party/wren-0.1.0/src/include)
target_include_directories(tic80core PRIVATE 3rd-party/moonscript)
target_include_directories(tic80core PRIVATE 3rd-party/fennel)
2018-05-17 16:32:25 +02:00
2018-05-18 13:56:45 +02:00
add_dependencies(tic80core lua lpeg wren giflib)
target_link_libraries(tic80core lua lpeg wren giflib)
2018-05-17 16:32:25 +02:00
2018-05-17 22:39:56 +02:00
################################
# SDL2
################################
2018-05-17 20:53:42 +02:00
if(WIN32)
set(HAVE_LIBC TRUE)
endif()
2018-05-18 18:40:56 +02:00
set(SDL_SHARED_ENABLED_BY_DEFAULT OFF)
2018-05-17 16:32:25 +02:00
add_subdirectory(3rd-party/SDL2-2.0.7)
2018-05-17 22:39:56 +02:00
################################
# SDL2 renderer example
################################
2018-05-17 16:32:25 +02:00
set(EXAMPLE_DIR examples)
set(EXAMPLE_SRC
${EXAMPLE_DIR}/sdl-renderer.c
)
2018-05-17 17:02:52 +02:00
if(WIN32)
2018-05-17 20:53:42 +02:00
add_executable(sdl-renderer WIN32 ${EXAMPLE_SRC})
2018-05-17 17:02:52 +02:00
else()
2018-05-17 20:53:42 +02:00
add_executable(sdl-renderer ${EXAMPLE_SRC})
2018-05-17 17:02:52 +02:00
endif()
2018-05-17 16:32:25 +02:00
2018-05-17 20:53:42 +02:00
target_include_directories(sdl-renderer PRIVATE 3rd-party/SDL2-2.0.7/include)
target_include_directories(sdl-renderer PRIVATE include)
target_include_directories(sdl-renderer PRIVATE src)
2018-05-17 16:32:25 +02:00
2018-05-18 13:56:45 +02:00
add_dependencies(sdl-renderer tic80core SDL2-static SDL2main)
target_link_libraries(sdl-renderer tic80core SDL2-static SDL2main)
2018-05-17 22:39:56 +02:00
################################
# SDL GPU
################################
set(SDLGPU_DIR 3rd-party/sdl-gpu/src)
set(SDLGPU_SRC
${SDLGPU_DIR}/renderer_GLES_1.c
${SDLGPU_DIR}/renderer_GLES_2.c
${SDLGPU_DIR}/renderer_GLES_3.c
${SDLGPU_DIR}/renderer_OpenGL_1.c
${SDLGPU_DIR}/renderer_OpenGL_1_BASE.c
${SDLGPU_DIR}/renderer_OpenGL_2.c
${SDLGPU_DIR}/renderer_OpenGL_3.c
${SDLGPU_DIR}/renderer_OpenGL_4.c
${SDLGPU_DIR}/SDL_gpu.c
${SDLGPU_DIR}/SDL_gpu_matrix.c
${SDLGPU_DIR}/SDL_gpu_renderer.c
${SDLGPU_DIR}/SDL_gpu_shapes.c
${SDLGPU_DIR}/externals/glew/glew.c
${SDLGPU_DIR}/externals/stb_image/stb_image.c
${SDLGPU_DIR}/externals/stb_image_write/stb_image_write.c
)
add_library(sdlgpu STATIC ${SDLGPU_SRC})
2018-05-18 18:13:56 +02:00
target_compile_definitions(sdlgpu PRIVATE GLEW_STATIC SDL_GPU_DISABLE_GLES SDL_GPU_DISABLE_OPENGL_3 SDL_GPU_DISABLE_OPENGL_4)
2018-05-17 22:39:56 +02:00
target_include_directories(sdlgpu PRIVATE 3rd-party/sdl-gpu/include)
target_include_directories(sdlgpu PRIVATE 3rd-party/sdl-gpu/src/externals/glew)
target_include_directories(sdlgpu PRIVATE 3rd-party/sdl-gpu/src/externals/glew/GL)
target_include_directories(sdlgpu PRIVATE 3rd-party/sdl-gpu/src/externals/stb_image)
target_include_directories(sdlgpu PRIVATE 3rd-party/sdl-gpu/src/externals/stb_image_write)
target_include_directories(sdlgpu PRIVATE 3rd-party/SDL2-2.0.7/include)
add_dependencies(sdlgpu SDL2-static)
2018-05-18 15:58:33 +02:00
target_link_libraries(sdlgpu SDL2-static)
if(WIN32)
target_link_libraries(sdlgpu opengl32)
endif()
2018-05-18 17:12:32 +02:00
if(LINUX)
target_link_libraries(sdlgpu GL)
endif()
if(APPLE)
FIND_LIBRARY(OPENGL_LIBRARY OpenGL)
target_link_libraries(sdlgpu ${OPENGL_LIBRARY})
2018-05-18 15:58:33 +02:00
endif()
2018-05-17 22:39:56 +02:00
################################
# SDL NET
################################
set(SDLNET_DIR 3rd-party/SDL2_net-2.0.1)
set(SDLNET_SRC
${SDLNET_DIR}/SDLnet.c
${SDLNET_DIR}/SDLnetTCP.c
${SDLNET_DIR}/SDLnetselect.c
)
add_library(sdlnet STATIC ${SDLNET_SRC})
target_include_directories(sdlnet PRIVATE 3rd-party/SDL2-2.0.7/include)
2018-05-18 15:58:33 +02:00
if(WIN32)
target_link_libraries(sdlnet ws2_32)
endif()
2018-05-17 22:39:56 +02:00
################################
# ZLIB
################################
2018-05-18 18:47:30 +02:00
set(ZLIB_DIR 3rd-party/zlib-1.2.11)
set(ZLIB_SRC
${ZLIB_DIR}/adler32.c
${ZLIB_DIR}/compress.c
${ZLIB_DIR}/crc32.c
${ZLIB_DIR}/deflate.c
${ZLIB_DIR}/gzclose.c
${ZLIB_DIR}/gzlib.c
${ZLIB_DIR}/gzread.c
${ZLIB_DIR}/gzwrite.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
)
add_library(zlib STATIC ${ZLIB_SRC})
2018-05-17 22:39:56 +02:00
################################
2018-05-18 14:08:58 +02:00
# TIC-80 lib
################################
set(TIC80LIB_DIR src)
set(TIC80LIB_SRC
${TIC80LIB_DIR}/studio.c
${TIC80LIB_DIR}/console.c
${TIC80LIB_DIR}/run.c
${TIC80LIB_DIR}/ext/md5.c
${TIC80LIB_DIR}/ext/gif.c
${TIC80LIB_DIR}/fs.c
${TIC80LIB_DIR}/tools.c
${TIC80LIB_DIR}/start.c
${TIC80LIB_DIR}/sprite.c
${TIC80LIB_DIR}/map.c
${TIC80LIB_DIR}/sfx.c
${TIC80LIB_DIR}/music.c
${TIC80LIB_DIR}/history.c
${TIC80LIB_DIR}/world.c
${TIC80LIB_DIR}/config.c
${TIC80LIB_DIR}/code.c
${TIC80LIB_DIR}/dialog.c
${TIC80LIB_DIR}/menu.c
${TIC80LIB_DIR}/surf.c
${TIC80LIB_DIR}/html.c
)
add_library(tic80lib STATIC ${TIC80LIB_SRC})
if(WIN32)
target_include_directories(tic80lib PRIVATE build/windows/include)
endif()
target_include_directories(tic80lib PRIVATE include)
target_include_directories(tic80lib PRIVATE 3rd-party/giflib-5.1.4/lib)
target_include_directories(tic80lib PRIVATE 3rd-party/zlib-1.2.11)
target_include_directories(tic80lib PRIVATE 3rd-party/lua-5.3.1/src)
2018-05-18 18:47:30 +02:00
add_dependencies(tic80lib tic80core zlib)
target_link_libraries(tic80lib tic80core zlib)
2018-05-18 14:08:58 +02:00
################################
# TIC-80 app
2018-05-17 22:39:56 +02:00
################################
set(TIC80_DIR src)
set(TIC80_SRC
${TIC80_DIR}/net.c
${TIC80_DIR}/system.c
2018-05-18 17:25:44 +02:00
${TIC80_DIR}/ext/file_dialog.c
2018-05-17 22:39:56 +02:00
)
2018-05-18 17:25:44 +02:00
if(APPLE)
set(TIC80_SRC ${TIC80_SRC} ${TIC80_DIR}/ext/file_dialog.m)
endif()
2018-05-17 22:39:56 +02:00
if(WIN32)
2018-05-21 14:58:52 +02:00
add_executable(tic80 WIN32 ${TIC80_SRC} build/windows/tic/tic80.rc)
2018-05-17 22:39:56 +02:00
else()
add_executable(tic80 ${TIC80_SRC})
endif()
target_include_directories(tic80 PRIVATE include)
target_include_directories(tic80 PRIVATE 3rd-party/SDL2-2.0.7/include)
target_include_directories(tic80 PRIVATE 3rd-party/sdl-gpu/include)
target_include_directories(tic80 PRIVATE 3rd-party/SDL2_net-2.0.1)
2018-05-18 17:25:44 +02:00
add_dependencies(tic80 tic80lib sdlgpu sdlnet SDL2main)
target_link_libraries(tic80 tic80lib sdlgpu sdlnet SDL2main)
if(LINUX)
include(FindPkgConfig)
if(NOT PKG_CONFIG_FOUND)
message(FATAL_ERROR "We need pkg-config to compile this project")
endif()
pkg_check_modules(GTK REQUIRED gtk+-3.0)
target_include_directories(tic80 PRIVATE ${GTK_INCLUDE_DIRS})
target_link_libraries(tic80 ${GTK_LIBRARIES})
endif()