cmake on macosx

This commit is contained in:
Vadim Grigoruk 2018-05-18 18:12:32 +03:00
parent 88cbbde234
commit d838f889a1
1 changed files with 35 additions and 12 deletions

View File

@ -3,6 +3,10 @@ cmake_minimum_required(VERSION 3.9)
project(TIC-80 C)
message("Building for target : ${CMAKE_SYSTEM_NAME}")
if(UNIX AND NOT APPLE)
set(LINUX TRUE)
endif()
set(CMAKE_C_STANDARD 99)
if(NOT CMAKE_BUILD_TYPE)
@ -16,12 +20,12 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
include(FindPkgConfig)
if(NOT PKG_CONFIG_FOUND AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
if(NOT PKG_CONFIG_FOUND AND LINUX)
message(FATAL_ERROR "We need pkg-config to compile this project")
endif()
#platform specific includes
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
if(LINUX)
pkg_check_modules(GTK REQUIRED gtk+-3.0)
endif()
@ -229,8 +233,13 @@ if(WIN32)
target_link_libraries(sdlgpu opengl32)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_link_libraries(sdlgpu GL)
if(LINUX)
target_link_libraries(sdlgpu GL)
endif()
if(APPLE)
FIND_LIBRARY(OPENGL_LIBRARY OpenGL)
target_link_libraries(sdlgpu ${OPENGL_LIBRARY})
endif()
################################
@ -300,6 +309,26 @@ target_include_directories(tic80lib PRIVATE 3rd-party/lua-5.3.1/src)
add_dependencies(tic80lib tic80core zlibstatic)
target_link_libraries(tic80lib tic80core zlibstatic)
################################
# File Save/Load dialog
################################
set(FILE_DIALOG_SRC src/ext/file_dialog.c)
if(APPLE)
set(FILE_DIALOG_SRC ${FILE_DIALOG_SRC} src/ext/file_dialog.m)
endif()
add_library(file_dialog STATIC ${FILE_DIALOG_SRC})
target_include_directories(file_dialog PRIVATE include)
target_include_directories(file_dialog PRIVATE 3rd-party/SDL2-2.0.7/include)
if(LINUX)
target_include_directories(file_dialog PRIVATE ${GTK_INCLUDE_DIRS})
target_link_libraries(file_dialog ${GTK_LIBRARIES})
endif()
################################
# TIC-80 app
################################
@ -308,7 +337,6 @@ set(TIC80_DIR src)
set(TIC80_SRC
${TIC80_DIR}/net.c
${TIC80_DIR}/system.c
${TIC80_DIR}/ext/file_dialog.c
)
if(WIN32)
@ -317,15 +345,10 @@ else()
add_executable(tic80 ${TIC80_SRC})
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_include_directories(tic80 PRIVATE ${GTK_INCLUDE_DIRS})
target_link_libraries(tic80 ${GTK_LIBRARIES})
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)
add_dependencies(tic80 tic80lib sdlgpu sdlnet SDL2main)
target_link_libraries(tic80 tic80lib sdlgpu sdlnet SDL2main)
add_dependencies(tic80 tic80lib file_dialog sdlgpu sdlnet SDL2main)
target_link_libraries(tic80 tic80lib file_dialog sdlgpu sdlnet SDL2main)