2020-12-15 23:00:46 +00:00
|
|
|
# CMake Project for Refresh
|
|
|
|
# Written by @thatcosmonaut
|
|
|
|
cmake_minimum_required(VERSION 2.8.12)
|
|
|
|
project(Refresh C)
|
|
|
|
|
|
|
|
# Options
|
|
|
|
option(BUILD_SHARED_LIBS "Build shared library" ON)
|
|
|
|
|
|
|
|
# Version
|
2022-03-04 01:31:58 +00:00
|
|
|
SET(LIB_MAJOR_VERSION "1")
|
2022-03-14 17:54:32 +00:00
|
|
|
SET(LIB_MINOR_VERSION "4")
|
2022-03-10 18:28:00 +00:00
|
|
|
SET(LIB_REVISION "0")
|
2020-12-15 23:00:46 +00:00
|
|
|
SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}")
|
|
|
|
|
|
|
|
# Build Type
|
|
|
|
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
|
|
|
# By default, we use Release
|
|
|
|
message(STATUS "Setting build type to 'Release' as none was specified.")
|
|
|
|
set(CMAKE_BUILD_TYPE "Release" CACHE
|
|
|
|
STRING "Choose the type of build." FORCE
|
|
|
|
)
|
|
|
|
|
|
|
|
# Set the possible values of build type for cmake-gui
|
|
|
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
|
|
|
|
STRINGS "Debug" "Release" "RelWithDebInfo"
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Platform Flags
|
|
|
|
if(APPLE)
|
|
|
|
set(CMAKE_MACOSX_RPATH ON)
|
|
|
|
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9)
|
|
|
|
set(LOBJC "objc")
|
|
|
|
elseif(WIN32)
|
|
|
|
# "Refresh.dll", not "libRefresh.dll"
|
|
|
|
set(CMAKE_SHARED_LIBRARY_PREFIX "")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Defines
|
|
|
|
add_definitions(
|
|
|
|
-DREFRESH_DRIVER_VULKAN
|
|
|
|
)
|
|
|
|
|
|
|
|
# Source lists
|
|
|
|
add_library(Refresh
|
|
|
|
# Public Headers
|
|
|
|
include/Refresh.h
|
2020-12-28 06:45:12 +00:00
|
|
|
include/Refresh_Image.h
|
2020-12-15 23:00:46 +00:00
|
|
|
# Internal Headers
|
|
|
|
src/Refresh_Driver.h
|
|
|
|
src/Refresh_Driver_Vulkan_vkfuncs.h
|
|
|
|
# Source Files
|
|
|
|
src/Refresh.c
|
|
|
|
src/Refresh_Driver_Vulkan.c
|
2020-12-28 06:45:12 +00:00
|
|
|
src/Refresh_Image.c
|
2020-12-15 23:00:46 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# Build flags
|
|
|
|
if(NOT MSVC)
|
|
|
|
set_property(TARGET Refresh PROPERTY COMPILE_FLAGS "-std=gnu99 -Wall -Wno-strict-aliasing -pedantic")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Refresh folders as includes, for other targets to consume
|
|
|
|
target_include_directories(Refresh PUBLIC
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Vulkan-Headers/include>
|
|
|
|
)
|
|
|
|
|
|
|
|
# MinGW builds should statically link libgcc
|
|
|
|
if(MINGW)
|
|
|
|
target_link_libraries(Refresh PRIVATE -static-libgcc)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Soname
|
|
|
|
set_target_properties(Refresh PROPERTIES OUTPUT_NAME "Refresh"
|
|
|
|
VERSION ${LIB_VERSION}
|
|
|
|
SOVERSION ${LIB_MAJOR_VERSION}
|
|
|
|
)
|
|
|
|
|
|
|
|
# SDL2 Dependency
|
|
|
|
if (DEFINED SDL2_INCLUDE_DIRS AND DEFINED SDL2_LIBRARIES)
|
|
|
|
message(STATUS "using pre-defined SDL2 variables SDL2_INCLUDE_DIRS and SDL2_LIBRARIES")
|
|
|
|
target_include_directories(Refresh PUBLIC "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>")
|
|
|
|
target_link_libraries(Refresh PUBLIC ${SDL2_LIBRARIES})
|
|
|
|
else()
|
|
|
|
# Only try to autodetect if both SDL2 variables aren't explicitly set
|
|
|
|
find_package(SDL2 CONFIG)
|
|
|
|
if (TARGET SDL2::SDL2)
|
|
|
|
message(STATUS "using TARGET SDL2::SDL2")
|
|
|
|
target_link_libraries(Refresh PUBLIC SDL2::SDL2)
|
|
|
|
elseif (TARGET SDL2)
|
|
|
|
message(STATUS "using TARGET SDL2")
|
|
|
|
target_link_libraries(Refresh PUBLIC SDL2)
|
|
|
|
else()
|
|
|
|
message(STATUS "no TARGET SDL2::SDL2, or SDL2, using variables")
|
|
|
|
target_include_directories(Refresh PUBLIC "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>")
|
|
|
|
target_link_libraries(Refresh PUBLIC ${SDL2_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
endif()
|