- streamlined CMake configuration of game libraries

https://forum.zdoom.org/viewtopic.php?t=67121
This commit is contained in:
alexey.lysiuk 2020-01-27 13:45:19 +02:00 committed by Christoph Oelckers
parent 1c8c2543cb
commit 5510df77be
7 changed files with 45 additions and 354 deletions

View file

@ -410,11 +410,6 @@ add_subdirectory( tools )
add_subdirectory( libraries/gdtoa )
add_subdirectory( wadsrc )
add_subdirectory( source )
add_subdirectory( source/duke3d )
add_subdirectory( source/blood )
add_subdirectory( source/rr )
add_subdirectory( source/sw )
add_subdirectory( source/exhumed )
if( NOT CMAKE_CROSSCOMPILING )
export(TARGETS ${CROSS_EXPORTS} FILE "${CMAKE_BINARY_DIR}/ImportExecutables.cmake" )

View file

@ -839,14 +839,18 @@ set (PCH_SOURCES
common/rendering/hwrenderer/utility/hw_shaderpatcher.cpp
)
if( MSVC )
enable_precompiled_headers( g_pch.h PCH_SOURCES )
# The original Build code was written with unsigned chars and unfortunately they still haven't been eliminated entirely.
# All other code should stay with signed chars. What a mess... :(
else()
# Temporary solution for compilers other than MSVC
set_source_files_properties( ${PCH_SOURCES} PROPERTIES COMPILE_FLAGS "-include g_pch.h" )
endif()
macro( use_precompiled_header )
if( MSVC )
enable_precompiled_headers( "${ARGV0}/g_pch.h" PCH_SOURCES )
# The original Build code was written with unsigned chars and unfortunately they still haven't been eliminated entirely.
# All other code should stay with signed chars. What a mess... :(
else()
# Temporary solution for compilers other than MSVC
set_source_files_properties( ${PCH_SOURCES} PROPERTIES COMPILE_FLAGS "-include g_pch.h" )
endif()
endmacro()
use_precompiled_header(".")
add_executable( ${PROJECT_NAME} WIN32 MACOSX_BUNDLE
${HEADER_FILES}
@ -1036,3 +1040,29 @@ source_group("OpenGL Backend" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/g
source_group("Build Engine" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/build/.+")
source_group("Build Engine\\Headers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/build/include/.+")
source_group("Build Engine\\Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/build/src/.+")
macro( add_game_library )
file( GLOB HEADER_FILES src/*.h )
if( NOT_COMPILED_SOURCE_FILES )
set_source_files_properties( ${NOT_COMPILED_SOURCE_FILES} PROPERTIES HEADER_FILE_ONLY TRUE )
endif()
use_precompiled_header("..")
add_library( ${ARGV0} STATIC
${PCH_SOURCES}
${HEADER_FILES}
${NOT_COMPILED_SOURCE_FILES}
)
endmacro()
require_stricmp()
require_strnicmp()
unset( PCH_SOURCES )
unset( HEADER_FILES )
unset( NOT_COMPILED_SOURCE_FILES )
add_subdirectory( duke3d )
add_subdirectory( blood )
add_subdirectory( rr )
add_subdirectory( sw )
add_subdirectory( exhumed )

View file

@ -1,49 +1,5 @@
cmake_minimum_required( VERSION 3.1.0 )
require_stricmp()
require_strnicmp()
# Build does not work with signed chars!
if (MSVC)
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /J /DNOONE_EXTENSIONS" )
else()
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -funsigned-char -Wno-missing-braces -Wno-char-subscripts -Wno-unused-variable -DNOONE_EXTENSIONS" )
endif()
include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/../../build/include" )
if (WIN32)
include_directories( "${ZLIB_INCLUDE_DIR}" "${ZMUSIC_INCLUDE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../../platform/windows/include" "${CMAKE_CURRENT_SOURCE_DIR}/../../platform/windows/include/vpx")
else ()
include_directories( "${ZLIB_INCLUDE_DIR}" "${ZMUSIC_INCLUDE_DIR}")
endif()
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/..
${CMAKE_CURRENT_SOURCE_DIR}/../build/include
${CMAKE_CURRENT_SOURCE_DIR}/../audiolib/include
${CMAKE_CURRENT_SOURCE_DIR}/../libsmackerdec/include
${CMAKE_CURRENT_SOURCE_DIR}/../thirdparty/include
${CMAKE_CURRENT_SOURCE_DIR}/../common
${CMAKE_CURRENT_SOURCE_DIR}/../common/utility
${CMAKE_CURRENT_SOURCE_DIR}/../common/console
${CMAKE_CURRENT_SOURCE_DIR}/../common/textures
${CMAKE_CURRENT_SOURCE_DIR}/../common/fonts
${CMAKE_CURRENT_SOURCE_DIR}/../common/2d
${CMAKE_CURRENT_SOURCE_DIR}/../common/music
${CMAKE_CURRENT_SOURCE_DIR}/../common/input
${CMAKE_CURRENT_SOURCE_DIR}/../platform
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/gl_load
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/gl/system
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/gl/renderer
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/gl/shaders
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/hwrenderer/data
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/hwrenderer/postprocessing
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/hwrenderer/utility
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering
)
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOONE_EXTENSIONS" )
set( PCH_SOURCES
src/actor.cpp
@ -120,23 +76,4 @@ set( PCH_SOURCES
src/d_menu.cpp
)
if( MSVC )
enable_precompiled_headers( ../g_pch.h PCH_SOURCES )
# The original Build code was written with unsigned chars and unfortunately they still haven't been eliminated entirely.
# All other code should stay with signed chars. What a mess... :(
#set_source_files_properties( ${PCH_SOURCES} PROPERTIES COMPILE_FLAGS "/J" )
else()
# Temporary solution for compilers other than MSVC
set_source_files_properties( ${PCH_SOURCES} PROPERTIES COMPILE_FLAGS "-include g_pch.h" )
endif()
file( GLOB HEADER_FILES
src/*.h
)
add_library( blood STATIC
${HEADER_FILES}
${PCH_SOURCES}
)
add_game_library( blood )

View file

@ -1,58 +1,8 @@
cmake_minimum_required( VERSION 3.1.0 )
require_stricmp()
require_strnicmp()
# Build does not work with signed chars!
if (MSVC)
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /J" )
else()
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -funsigned-char -Wno-missing-braces -Wno-char-subscripts -Wno-unused-variable" )
endif()
include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/../../build/include" )
if (WIN32)
include_directories( "${ZLIB_INCLUDE_DIR}" "${ZMUSIC_INCLUDE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../../platform/windows/include" "${CMAKE_CURRENT_SOURCE_DIR}/../../platform/windows/include/vpx")
else ()
include_directories( "${ZLIB_INCLUDE_DIR}" "${ZMUSIC_INCLUDE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../platform/posix")
endif()
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/..
${CMAKE_CURRENT_SOURCE_DIR}/../build/include
${CMAKE_CURRENT_SOURCE_DIR}/../audiolib/include
${CMAKE_CURRENT_SOURCE_DIR}/../libsmackerdec/include
${CMAKE_CURRENT_SOURCE_DIR}/../thirdparty/include
${CMAKE_CURRENT_SOURCE_DIR}/../common
${CMAKE_CURRENT_SOURCE_DIR}/../common/utility
${CMAKE_CURRENT_SOURCE_DIR}/../common/console
${CMAKE_CURRENT_SOURCE_DIR}/../common/textures
${CMAKE_CURRENT_SOURCE_DIR}/../common/fonts
${CMAKE_CURRENT_SOURCE_DIR}/../common/2d
${CMAKE_CURRENT_SOURCE_DIR}/../common/music
${CMAKE_CURRENT_SOURCE_DIR}/../common/input
${CMAKE_CURRENT_SOURCE_DIR}/../platform
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/gl_load
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/gl/system
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/gl/renderer
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/gl/shaders
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/hwrenderer/data
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/hwrenderer/postprocessing
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/hwrenderer/utility
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering
${CMAKE_CURRENT_SOURCE_DIR}/../${SYSTEM_SOURCES_DIR}
)
set( NOT_COMPILED_SOURCE_FILES
src/gamestructures.cpp
)
set_source_files_properties( ${NOT_COMPILED_SOURCE_FILES} PROPERTIES HEADER_FILE_ONLY TRUE )
set( PCH_SOURCES
src/actors.cpp
src/anim.cpp
@ -80,24 +30,5 @@ set( PCH_SOURCES
src/soundsdyn.cpp
src/d_menu.cpp
)
if( MSVC )
enable_precompiled_headers( ../g_pch.h PCH_SOURCES )
# The original Build code was written with unsigned chars and unfortunately they still haven't been eliminated entirely.
# All other code should stay with signed chars. What a mess... :(
#set_source_files_properties( ${PCH_SOURCES} PROPERTIES COMPILE_FLAGS "/J" )
else()
# Temporary solution for compilers other than MSVC
set_source_files_properties( ${PCH_SOURCES} PROPERTIES COMPILE_FLAGS "-include g_pch.h" )
endif()
file( GLOB HEADER_FILES
src/*.h
)
add_library( duke3d STATIC
${HEADER_FILES}
${PCH_SOURCES}
${NOT_COMPILED_SOURCE_FILES}
)
add_game_library( duke3d )

View file

@ -1,55 +1,4 @@
cmake_minimum_required( VERSION 3.1.0 )
require_stricmp()
require_strnicmp()
# Build does not work with signed chars!
if (MSVC)
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /J" )
else()
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -funsigned-char -Wno-missing-braces -Wno-char-subscripts -Wno-unused-variable" )
endif()
include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/../../build/include" )
if (WIN32)
include_directories( "${ZLIB_INCLUDE_DIR}" "${ZMUSIC_INCLUDE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../../platform/windows/include" "${CMAKE_CURRENT_SOURCE_DIR}/../../platform/windows/include/vpx")
else ()
include_directories( "${ZLIB_INCLUDE_DIR}" "${ZMUSIC_INCLUDE_DIR}")
endif()
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/..
${CMAKE_CURRENT_SOURCE_DIR}/../build/include
${CMAKE_CURRENT_SOURCE_DIR}/../libsmackerdec/include
${CMAKE_CURRENT_SOURCE_DIR}/../thirdparty/include
${CMAKE_CURRENT_SOURCE_DIR}/../common
${CMAKE_CURRENT_SOURCE_DIR}/../common/utility
${CMAKE_CURRENT_SOURCE_DIR}/../common/console
${CMAKE_CURRENT_SOURCE_DIR}/../common/textures
${CMAKE_CURRENT_SOURCE_DIR}/../common/fonts
${CMAKE_CURRENT_SOURCE_DIR}/../common/2d
${CMAKE_CURRENT_SOURCE_DIR}/../common/music
${CMAKE_CURRENT_SOURCE_DIR}/../common/input
${CMAKE_CURRENT_SOURCE_DIR}/../platform
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/gl_load
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/gl/system
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/gl/renderer
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/gl/shaders
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/hwrenderer/data
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/hwrenderer/postprocessing
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/hwrenderer/utility
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering
)
#set( NOT_COMPILED_SOURCE_FILES
# src/gamestructures.cpp
#)
#set_source_files_properties( ${NOT_COMPILED_SOURCE_FILES} PROPERTIES HEADER_FILE_ONLY TRUE )
set( PCH_SOURCES
src/aistuff.cpp
src/anims.cpp
@ -108,23 +57,4 @@ set( PCH_SOURCES
src/d_menu.cpp
)
if( MSVC )
enable_precompiled_headers( ../g_pch.h PCH_SOURCES )
# The original Build code was written with unsigned chars and unfortunately they still haven't been eliminated entirely.
# All other code should stay with signed chars. What a mess... :(
#set_source_files_properties( ${PCH_SOURCES} PROPERTIES COMPILE_FLAGS "/J" )
else()
# Temporary solution for compilers other than MSVC
set_source_files_properties( ${PCH_SOURCES} PROPERTIES COMPILE_FLAGS "-include g_pch.h" )
endif()
file( GLOB HEADER_FILES
src/*.h
)
add_library( exhumed STATIC
${HEADER_FILES}
${PCH_SOURCES}
#${NOT_COMPILED_SOURCE_FILES}
)
add_game_library( exhumed )

View file

@ -1,53 +1,3 @@
cmake_minimum_required( VERSION 3.1.0 )
require_stricmp()
require_strnicmp()
# Build does not work with signed chars!
if (MSVC)
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /J" )
else()
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -funsigned-char -Wno-missing-braces -Wno-char-subscripts -Wno-unused-variable" )
endif()
include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/../../build/include" )
if (WIN32)
include_directories( "${ZLIB_INCLUDE_DIR}" "${ZMUSIC_INCLUDE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../../platform/windows/include" "${CMAKE_CURRENT_SOURCE_DIR}/../../platform/windows/include/vpx")
else ()
include_directories( "${ZLIB_INCLUDE_DIR}" "${ZMUSIC_INCLUDE_DIR}")
endif()
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/..
${CMAKE_CURRENT_SOURCE_DIR}/../build/include
${CMAKE_CURRENT_SOURCE_DIR}/../audiolib/include
${CMAKE_CURRENT_SOURCE_DIR}/../libsmackerdec/include
${CMAKE_CURRENT_SOURCE_DIR}/../thirdparty/include
${CMAKE_CURRENT_SOURCE_DIR}/../common
${CMAKE_CURRENT_SOURCE_DIR}/../common/utility
${CMAKE_CURRENT_SOURCE_DIR}/../common/console
${CMAKE_CURRENT_SOURCE_DIR}/../common/textures
${CMAKE_CURRENT_SOURCE_DIR}/../common/fonts
${CMAKE_CURRENT_SOURCE_DIR}/../common/2d
${CMAKE_CURRENT_SOURCE_DIR}/../common/music
${CMAKE_CURRENT_SOURCE_DIR}/../common/input
${CMAKE_CURRENT_SOURCE_DIR}/../platform
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/gl_load
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/gl/system
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/gl/renderer
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/gl/shaders
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/hwrenderer/data
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/hwrenderer/postprocessing
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/hwrenderer/utility
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering
)
set( NOT_COMPILED_SOURCE_FILES
)
set_source_files_properties( ${NOT_COMPILED_SOURCE_FILES} PROPERTIES HEADER_FILE_ONLY TRUE )
set( PCH_SOURCES
src/actors.cpp
@ -76,21 +26,4 @@ set( PCH_SOURCES
src/soundsdyn.cpp
)
if( MSVC )
enable_precompiled_headers( ../g_pch.h PCH_SOURCES )
# The original Build code was written with unsigned chars and unfortunately they still haven't been eliminated entirely.
# All other code should stay with signed chars. What a mess... :(
#set_source_files_properties( ${PCH_SOURCES} PROPERTIES COMPILE_FLAGS "/J" )
else()
# Temporary solution for compilers other than MSVC
set_source_files_properties( ${PCH_SOURCES} PROPERTIES COMPILE_FLAGS "-include g_pch.h" )
endif()
file( GLOB HEADER_FILES
src/*.h
)
add_library( rr STATIC
${HEADER_FILES}
${PCH_SOURCES}
${NOT_COMPILED_SOURCE_FILES}
)
add_game_library( rr )

View file

@ -1,49 +1,3 @@
cmake_minimum_required( VERSION 3.1.0 )
require_stricmp()
require_strnicmp()
# Build does not work with signed chars!
if (MSVC)
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /J" )
else()
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -funsigned-char -Wno-missing-braces -Wno-char-subscripts -Wno-unused-variable" )
endif()
include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/../../build/include" )
if (WIN32)
include_directories( "${ZLIB_INCLUDE_DIR}" "${ZMUSIC_INCLUDE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../../platform/windows/include" "${CMAKE_CURRENT_SOURCE_DIR}/../../platform/windows/include/vpx")
else ()
include_directories( "${ZLIB_INCLUDE_DIR}" "${ZMUSIC_INCLUDE_DIR}")
endif()
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/..
${CMAKE_CURRENT_SOURCE_DIR}/../build/include
${CMAKE_CURRENT_SOURCE_DIR}/../audiolib/include
${CMAKE_CURRENT_SOURCE_DIR}/../libsmackerdec/include
${CMAKE_CURRENT_SOURCE_DIR}/../thirdparty/include
${CMAKE_CURRENT_SOURCE_DIR}/../common
${CMAKE_CURRENT_SOURCE_DIR}/../common/utility
${CMAKE_CURRENT_SOURCE_DIR}/../common/console
${CMAKE_CURRENT_SOURCE_DIR}/../common/textures
${CMAKE_CURRENT_SOURCE_DIR}/../common/fonts
${CMAKE_CURRENT_SOURCE_DIR}/../common/2d
${CMAKE_CURRENT_SOURCE_DIR}/../common/music
${CMAKE_CURRENT_SOURCE_DIR}/../common/input
${CMAKE_CURRENT_SOURCE_DIR}/../platform
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/gl_load
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/gl/system
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/gl/renderer
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/gl/shaders
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/hwrenderer/data
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/hwrenderer/postprocessing
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering/hwrenderer/utility
${CMAKE_CURRENT_SOURCE_DIR}/../common/rendering
)
set( PCH_SOURCES
src/actor.cpp
@ -120,23 +74,4 @@ set( PCH_SOURCES
src/d_menu.cpp
)
if( MSVC )
enable_precompiled_headers( ../g_pch.h PCH_SOURCES )
# The original Build code was written with unsigned chars and unfortunately they still haven't been eliminated entirely.
# All other code should stay with signed chars. What a mess... :(
#set_source_files_properties( ${PCH_SOURCES} PROPERTIES COMPILE_FLAGS "/J" )
else()
# Temporary solution for compilers other than MSVC
set_source_files_properties( ${PCH_SOURCES} PROPERTIES COMPILE_FLAGS "-include g_pch.h" )
endif()
file( GLOB HEADER_FILES
src/*.h
)
add_library( sw STATIC
${HEADER_FILES}
${PCH_SOURCES}
)
add_game_library( sw )