Skip to content

Commit

Permalink
CMake tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
dashodanger committed Sep 30, 2024
1 parent 5da6bc6 commit 6a5b4df
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 55 deletions.
69 changes: 29 additions & 40 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
cmake_minimum_required(VERSION 3.12..3.20)

if(NOT CONSOLE_ONLY)
add_subdirectory(libraries/fltk EXCLUDE_FROM_ALL)
endif()
add_subdirectory(libraries/miniz EXCLUDE_FROM_ALL)
add_subdirectory(libraries/physfs EXCLUDE_FROM_ALL)
add_subdirectory(libraries/steve EXCLUDE_FROM_ALL)

project(
obsidian
LANGUAGES C CXX
Expand All @@ -21,11 +14,7 @@ add_compile_definitions(OBSIDIAN_TIMESTAMP="${BUILD_TIMESTAMP}")
if(CONSOLE_ONLY)
add_compile_definitions(OBSIDIAN_CONSOLE_ONLY)
endif()
if(WIN32)
add_compile_definitions(WIN32_LEAN_AND_MEAN)
add_compile_definitions(UNICODE)
add_compile_definitions(_UNICODE)
elseif(NOT APPLE AND NOT CONSOLE_ONLY)
if(NOT WIN32 AND NOT APPLE AND NOT CONSOLE_ONLY)
add_compile_definitions(USE_XFT)
endif()
if(MSVC)
Expand All @@ -52,6 +41,16 @@ if(${CMAKE_SYSTEM} MATCHES "OpenBSD")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I /usr/X11R6/include")
endif()

if(UNIX)
if(NOT CONSOLE_ONLY
AND NOT APPLE
)
find_package(Fontconfig REQUIRED)
endif()
endif()

add_subdirectory(libraries)

set(OBSIDIAN_SOURCE_FILES
source/bsp_level.cc
source/bsp_misc.cc
Expand Down Expand Up @@ -126,26 +125,6 @@ add_executable(
${OBSIDIAN_SOURCE_FILES}
)

target_include_directories(obsidian SYSTEM PRIVATE libraries/fastPRNG)
if(NOT CONSOLE_ONLY)
target_include_directories(obsidian SYSTEM PRIVATE libraries/fltk)
target_include_directories(
obsidian SYSTEM PRIVATE "${PROJECT_BINARY_DIR}/libraries/fltk"
) # Hack for FLTK 1.4 (for now)
endif()
target_include_directories(obsidian SYSTEM PRIVATE libraries/minilua)
target_include_directories(obsidian SYSTEM PRIVATE libraries/miniz)
target_include_directories(obsidian SYSTEM PRIVATE libraries/physfs/src)
target_include_directories(obsidian SYSTEM PRIVATE libraries/steve/src)

if(UNIX)
if(NOT CONSOLE_ONLY
AND NOT APPLE
)
find_package(Fontconfig REQUIRED)
endif()
endif()

# Copies executables to local install directory after build
add_custom_command(
TARGET obsidian
Expand All @@ -159,8 +138,10 @@ if(UNIX)
if(NOT CONSOLE_ONLY)
target_link_libraries(
obsidian
PRIVATE fltk
PRIVATE fastPRNG
fltk
fltk_images
minilua
miniz
physfs-static
steve
Expand All @@ -171,30 +152,34 @@ if(UNIX)
)
else()
target_link_libraries(
obsidian PRIVATE miniz physfs-static steve
obsidian PRIVATE fastPRNG minilua miniz physfs-static steve
)
endif()
elseif(${CMAKE_SYSTEM} MATCHES "BSD")
if(NOT CONSOLE_ONLY)
target_link_libraries(
obsidian
PRIVATE fltk
PRIVATE fastPRNG
fltk
fltk_images
minilua
miniz
physfs-static
steve
)
else()
target_link_libraries(
obsidian PRIVATE miniz physfs-static steve
obsidian PRIVATE fastPRNG minilua miniz physfs-static steve
)
endif()
else()
if(NOT CONSOLE_ONLY)
target_link_libraries(
obsidian
PRIVATE fltk
PRIVATE fastPRNG
fltk
fltk_images
minilua
miniz
physfs-static
fontconfig
Expand All @@ -204,7 +189,9 @@ if(UNIX)
else()
target_link_libraries(
obsidian
PRIVATE miniz
PRIVATE fastPRNG
minilua
miniz
physfs-static
pthread
steve
Expand All @@ -215,15 +202,17 @@ else()
if(NOT CONSOLE_ONLY)
target_link_libraries(
obsidian
PRIVATE fltk
PRIVATE fastPRNG
fltk
fltk_images
minilua
miniz
physfs-static
steve
)
else()
target_link_libraries(
obsidian PRIVATE miniz physfs-static steve
obsidian PRIVATE fastPRNG minilua miniz physfs-static steve
)
endif()
endif()
8 changes: 8 additions & 0 deletions libraries/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
add_subdirectory(fastPRNG)
if(NOT CONSOLE_ONLY)
add_subdirectory(fltk)
endif()
add_subdirectory(minilua)
add_subdirectory(miniz)
add_subdirectory(physfs)
add_subdirectory(steve)
8 changes: 8 additions & 0 deletions libraries/fastPRNG/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
##########################################
# fastPRNG
##########################################

add_library(fastPRNG INTERFACE)

target_include_directories(fastPRNG INTERFACE
${CMAKE_CURRENT_SOURCE_DIR})
7 changes: 7 additions & 0 deletions libraries/minilua/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
##########################################
# minilua
##########################################

add_library(minilua minilua.cc)

target_include_directories(minilua PUBLIC ./)
2 changes: 2 additions & 0 deletions libraries/minilua/minilua.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#define LUA_IMPL
#include "minilua.h"
18 changes: 7 additions & 11 deletions libraries/miniz/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# AJBSP CMake Script
cmake_minimum_required(VERSION 3.2.2)
##########################################
# miniz
##########################################

project(
add_library(
miniz
LANGUAGES C
VERSION 0.1.0
)
miniz.c
)

set(CMAKE_CC_FLAGS
"-O2 -ffast-math -fno-strict-aliasing -DINLINE_G=inline -Wall"
)

add_library(miniz miniz.c)
target_include_directories(miniz PUBLIC ./)
8 changes: 7 additions & 1 deletion libraries/steve/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
##########################################
# steve
##########################################

project(steve)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)

file(GLOB_RECURSE SOURCES src/*.cpp src/*.h)

add_library(steve ${SOURCES})
add_library(steve ${SOURCES})

target_include_directories(steve PUBLIC ./src)
4 changes: 1 addition & 3 deletions source/m_lua.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@
#include "lib_util.h"
#include "m_trans.h"
#include "main.h"
#include "minilua.h"
#include "physfs.h"
#include "sys_assert.h"
#include "sys_debug.h"
#include "sys_xoshiro.h"

#define LUA_IMPL
#include "minilua.h"

static lua_State *LUA_ST;

static bool has_loaded = false;
Expand Down

0 comments on commit 6a5b4df

Please sign in to comment.