Skip to content

Commit

Permalink
CMake refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Masterkatze committed Nov 19, 2023
1 parent 4fe8751 commit 8044a7b
Show file tree
Hide file tree
Showing 53 changed files with 6,418 additions and 6,276 deletions.
284 changes: 98 additions & 186 deletions CMakeLists.txt

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion Externals/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,12 @@ endif()
add_subdirectory(GameSpy)
add_subdirectory(OPCODE)
add_subdirectory(ode)
#add_subdirectory(NVTT)
add_subdirectory(NVTT)
add_subdirectory(imgui-proj)

if (NOT TARGET xrLuabind)
message(FATAL_ERROR
"You probably have downloaded OpenXRay sources as ZIP archive, you can't do that. Use git to clone the repository.\n"
"Read the build instructions: https://github.com/OpenXRay/xray-16/wiki"
)
endif()
2 changes: 1 addition & 1 deletion Externals/GameSpy
Submodule GameSpy updated 1 files
+175 −176 src/GameSpy/CMakeLists.txt
2 changes: 1 addition & 1 deletion Externals/LuaJIT-proj/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include(luajit.cmake)
include(luajit.cmake) # TODO do not include and move contents of luajit.cmake file here
8 changes: 1 addition & 7 deletions Externals/LuaJIT-proj/luajit.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ elseif ("${TARGET_TESTARCH}" MATCHES "LJ_TARGET_MIPS")
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "e2k") # MCST Elbrus 2000
set(TARGET_LJARCH "e2k")
else()
message(FATAL_ERROR "Unsupported luajit target architecture")
message(FATAL_ERROR "Unsupported luajit target architecture: ${TARGET_TESTARCH}")
endif()

string(APPEND TARGET_ARCH "-DLUAJIT_TARGET=LUAJIT_ARCH_${TARGET_LJARCH}")
Expand Down Expand Up @@ -357,8 +357,6 @@ set(BUILDVM_SRC
"${LUAJIT_DIR}/host/buildvm.h"
)

group_sources(BUILDVM_SRC)

add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/HostBuildTools/buildvm/buildvm"
COMMAND ${CMAKE_COMMAND}
Expand Down Expand Up @@ -436,8 +434,6 @@ SET(DEPS
"${CMAKE_CURRENT_BINARY_DIR}/lj_folddef.h"
)

group_sources(DEPS)

if (CMAKE_UNITY_BUILD)
set(LJCORE_C "${LUAJIT_DIR}/ljamalg.c")
else()
Expand Down Expand Up @@ -558,8 +554,6 @@ else()
)
endif()

group_sources(LJCORE_C)

if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(LIB_NAME ${PROJECT_NAME}-debug)
else()
Expand Down
4 changes: 0 additions & 4 deletions Externals/NVTT/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
cmake_minimum_required(VERSION 3.10)

project(nvtt)

add_definitions(-DHAVE_SIGNAL_H -DHAVE_EXECINFO_H)

add_subdirectory(src/nvcore)
add_subdirectory(src/nvimage)
add_subdirectory(src/nvmath)
Expand Down
91 changes: 44 additions & 47 deletions Externals/NVTT/src/nvcore/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,62 +1,59 @@
project(nvcore)
option(NVCORE_SHARED "Build nvcore as shared library" OFF)

set(NVCORE_SHARED OFF)

# XXX: check if poshlib is needed?
add_subdirectory(poshlib)

set(SRC_FILES
"nvcore.h"
"Ptr.h"
"BitArray.h"
"Memory.h"
"Memory.cpp"
"Debug.h"
"Debug.cpp"
"Containers.h"
"StrLib.h"
"StrLib.cpp"
"Stream.h"
"StdStream.h"
"TextReader.h"
"TextReader.cpp"
"TextWriter.h"
"TextWriter.cpp"
"Radix.h"
"Radix.cpp"
"Library.h"
"Library.cpp"
)

group_sources(SRC_FILES)

if (NVCORE_SHARED)
add_library(${PROJECT_NAME} SHARED ${SRC_FILES})
add_library(nvcore SHARED)

target_compile_definitions(nvcore
PRIVATE
NVCORE_SHARED
)
else()
add_library(${PROJECT_NAME} STATIC ${SRC_FILES})
add_library(nvcore STATIC)
endif()

target_include_directories(${PROJECT_NAME}
target_sources(nvcore
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/Externals/NVTT/src
${CMAKE_SOURCE_DIR}/Externals/NVTT/include
nvcore.h
Ptr.h
BitArray.h
Memory.h
Memory.cpp
Debug.h
Debug.cpp
Containers.h
StrLib.h
StrLib.cpp
Stream.h
StdStream.h
TextReader.h
TextReader.cpp
TextWriter.h
TextWriter.cpp
Radix.h
Radix.cpp
Library.h
Library.cpp
)

target_compile_definitions(${PROJECT_NAME}
target_include_directories(nvcore
PUBLIC
"${CMAKE_SOURCE_DIR}/Externals/NVTT/src"
"${CMAKE_SOURCE_DIR}/Externals/NVTT/include"
)

target_compile_definitions(nvcore
PRIVATE
-DNVCORE_EXPORTS
$<$<BOOL:${NVCORE_SHARED}>:-DNVCORE_SHARED=1>
NVCORE_EXPORTS
HAVE_EXECINFO_H
HAVE_SIGNAL_H
)

if (UNIX)
target_link_libraries(${PROJECT_NAME}
PRIVATE
${CMAKE_DL_LIBS} # XXX: why?
)
endif()
set_target_properties(nvcore PROPERTIES
POSITION_INDEPENDENT_CODE ON
)

install(TARGETS ${PROJECT_NAME} LIBRARY
DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
install(TARGETS nvcore LIBRARY
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)
10 changes: 5 additions & 5 deletions Externals/NVTT/src/nvcore/poshlib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set(SRC_FILES
"posh.c"
"posh.h"
)
add_library(posh STATIC)

add_library(posh STATIC ${SRC_FILES})
target_sources(posh PRIVATE
posh.c
posh.h
)
105 changes: 49 additions & 56 deletions Externals/NVTT/src/nvimage/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,72 +1,65 @@
PROJECT(nvimage)

set(NVIMAGE_SHARED OFF)

set(SRC_FILES
"nvimage.h"
"FloatImage.h"
"FloatImage.cpp"
"Filter.h"
"Filter.cpp"
"Image.h"
"Image.cpp"
"ImageIO.h"
"ImageIO.cpp"
"ColorBlock.h"
"ColorBlock.cpp"
"BlockDXT.h"
"BlockDXT.cpp"
"HoleFilling.h"
"HoleFilling.cpp"
"DirectDrawSurface.h"
"DirectDrawSurface.cpp"
"Quantize.h"
"Quantize.cpp"
"NormalMap.h"
"NormalMap.cpp"
"NormalMipmap.h"
"NormalMipmap.cpp"
"PsdFile.h"
"TgaFile.h"
)

group_sources(SRC_FILES)
option(NVIMAGE_SHARED "Build nvimage as shared library" OFF)

if (NVIMAGE_SHARED)
add_library(${PROJECT_NAME} SHARED ${SRC_FILES})
add_library(nvimage SHARED)

target_compile_definitions(nvimage
PRIVATE
NVIMAGE_SHARED=1
)
else()
add_library(${PROJECT_NAME} STATIC ${SRC_FILES})
add_library(nvimage STATIC)
endif()

target_include_directories(${PROJECT_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/Externals/NVTT/src
${CMAKE_SOURCE_DIR}/Externals/NVTT/include
$<$<BOOL:${PNG_FOUND}>:${PNG_INCLUDE_DIR}>
$<$<BOOL:${JPEG_FOUND}>:${JPEG_INCLUDE_DIR}>
$<$<BOOL:${TIFF_FOUND}>:${TIFF_INCLUDE_DIR}>
$<$<BOOL:${OPENEXR_FOUND}>:${OPENEXR_INCLUDE_PATHS}>
target_sources(nvimage PRIVATE
nvimage.h
FloatImage.h
FloatImage.cpp
Filter.h
Filter.cpp
Image.h
Image.cpp
ImageIO.h
ImageIO.cpp
ColorBlock.h
ColorBlock.cpp
BlockDXT.h
BlockDXT.cpp
HoleFilling.h
HoleFilling.cpp
DirectDrawSurface.h
DirectDrawSurface.cpp
Quantize.h
Quantize.cpp
NormalMap.h
NormalMap.cpp
NormalMipmap.h
NormalMipmap.cpp
PsdFile.h
TgaFile.h
)

target_link_libraries(${PROJECT_NAME}
PRIVATE
target_link_libraries(nvimage
PUBLIC
nvcore
nvmath
PRIVATE
posh
$<$<BOOL:${PNG_FOUND}>:${PNG_LIBRARIES}>
$<$<BOOL:${JPEG_FOUND}>:${JPEG_LIBRARIES}>
$<$<BOOL:${TIFF_FOUND}>:${TIFF_LIBRARIES}>
$<$<BOOL:${OPENEXR_FOUND}>:${OPENEXR_LIBRARIES}>
$<$<BOOL:${PNG_FOUND}>:PNG::PNG>
$<$<BOOL:${JPEG_FOUND}>:JPEG::JPEG>
$<$<BOOL:${TIFF_FOUND}>:TIFF::TIFF>
$<$<BOOL:${OPENEXR_FOUND}>:OpenEXR::OpenEXR>
)

target_compile_definitions(${PROJECT_NAME}
target_compile_definitions(nvimage
PRIVATE
-DNVIMAGE_EXPORTS
$<$<BOOL:${NVIMAGE_SHARED}>:-DNVIMAGE_SHARED=1>
NVIMAGE_EXPORTS
)

set_property(TARGET nvimage PROPERTY
POSITION_INDEPENDENT_CODE ON
)

install(TARGETS ${PROJECT_NAME} LIBRARY
DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
install(TARGETS nvimage LIBRARY
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)
72 changes: 32 additions & 40 deletions Externals/NVTT/src/nvmath/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,54 +1,46 @@
PROJECT(nvmath)

set(NVMATH_SHARED OFF)

set(SRC_FILES
"nvmath.h"
"Vector.h"
"Matrix.h"
"Quaternion.h"
"Box.h"
"Color.h"
"Montecarlo.h"
"Montecarlo.cpp"
"Random.h"
"Random.cpp"
"SphericalHarmonic.h"
"SphericalHarmonic.cpp"
"Basis.h"
"Basis.cpp"
"Triangle.h"
"Triangle.cpp"
"TriBox.cpp"
)

group_sources(SRC_FILES)
option(NVMATH_SHARED "Build nvmath as shared library" OFF)

if (NVMATH_SHARED)
add_library(${PROJECT_NAME} SHARED ${SRC_FILES})
add_library(nvmath SHARED)

target_compile_definitions(nvmath
PRIVATE
NVCORE_SHARED
)
else()
add_library(${PROJECT_NAME} STATIC ${SRC_FILES})
add_library(nvmath STATIC)
endif()

target_include_directories(${PROJECT_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/Externals/NVTT/src
${CMAKE_SOURCE_DIR}/Externals/NVTT/include
target_sources(nvmath PRIVATE
nvmath.h
Vector.h
Matrix.h
Quaternion.h
Box.h
Color.h
Montecarlo.h
Montecarlo.cpp
Random.h
Random.cpp
SphericalHarmonic.h
SphericalHarmonic.cpp
Basis.h
Basis.cpp
Triangle.h
Triangle.cpp
TriBox.cpp
)

target_link_libraries(${PROJECT_NAME}
PRIVATE
target_link_libraries(nvmath
PUBLIC
nvcore
)

target_compile_definitions(${PROJECT_NAME}
target_compile_definitions(nvmath
PRIVATE
-DNVCORE_EXPORTS
$<$<BOOL:${NVMATH_SHARED}>:-DNVMATH_SHARED=1>
NVCORE_EXPORTS
)

install(TARGETS ${PROJECT_NAME} LIBRARY
DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
install(TARGETS nvmath LIBRARY
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)
Loading

0 comments on commit 8044a7b

Please sign in to comment.