Skip to content
This repository was archived by the owner on Apr 29, 2024. It is now read-only.

Commit d71617e

Browse files
authored
Improve CMake files for Linux (#474)
* cmake: improve building DXVK Native * cmake: move Linux dependencies to linux.cmake * cmake: add option STORM_USE_CONAN_SDL - use sdl from conan If options is turned off - search and use SDL from system * cmake: add -O3 flag for Release and -g for Debug on Linux
1 parent 7ce19e2 commit d71617e

9 files changed

Lines changed: 56 additions & 40 deletions

File tree

CMakeLists.txt

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ include(StormSetup)
88
option(STORM_ENABLE_CRASH_REPORTS "Enable automatic crash reports" OFF)
99
option(STORM_ENABLE_STEAM "Enable Steam integration" OFF)
1010
option(STORM_ENABLE_SAFE_MODE "Enable additional runtime checks" OFF)
11+
option(STORM_USE_CONAN_SDL "Use sdl from conan" ON)
1112

1213
### Set up output paths
1314
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
@@ -16,6 +17,12 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Debug
1617

1718
set(STORM_WATERMARK_FILE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/watermark.hpp CACHE FILEPATH "Include file containing build revision, etc." FORCE)
1819

20+
if (WIN32)
21+
set(SDL2_LIBRARIES "sdl")
22+
else()
23+
include(linux)
24+
endif()
25+
1926
### Set up third-party dependencies
2027
set(ENV{CONAN_REVISIONS_ENABLED} 1)
2128
conan_add_remote(NAME bincrafters
@@ -26,7 +33,7 @@ conan_add_remote(NAME storm
2633
URL https://storm.jfrog.io/artifactory/api/conan/conan-remote
2734
VERIFY_SSL True
2835
)
29-
normalize_booleans(STORM_ENABLE_CRASH_REPORTS STORM_ENABLE_STEAM)
36+
normalize_booleans(STORM_ENABLE_CRASH_REPORTS STORM_ENABLE_STEAM STORM_USE_CONAN_SDL)
3037
conan_cmake_run(CONANFILE conanfile.py
3138
BASIC_SETUP CMAKE_TARGETS
3239
BUILD missing
@@ -35,32 +42,9 @@ conan_cmake_run(CONANFILE conanfile.py
3542
watermark_file=${STORM_WATERMARK_FILE}
3643
crash_reports=${STORM_ENABLE_CRASH_REPORTS}
3744
steam=${STORM_ENABLE_STEAM}
45+
conan_sdl=${STORM_USE_CONAN_SDL}
3846
)
3947

40-
if (NOT WIN32)
41-
message("Using DXVK-native for D3D9 API")
42-
43-
include(ExternalProject)
44-
ExternalProject_Add(dxvk-native
45-
GIT_REPOSITORY https://github.com/Joshua-Ashton/dxvk-native
46-
GIT_TAG a2dc99c407340432d4ba5bfa29efa685c27942ea
47-
GIT_SHALLOW ON
48-
BUILD_ALWAYS OFF
49-
CONFIGURE_HANDLED_BY_BUILD ON
50-
CONFIGURE_COMMAND meson ../dxvk-native
51-
BUILD_COMMAND ninja
52-
INSTALL_COMMAND ""
53-
)
54-
ExternalProject_Get_property(dxvk-native SOURCE_DIR BINARY_DIR)
55-
set(DXVK_NATIVE_INCLUDE_DIRS
56-
"${SOURCE_DIR}/include/native/directx"
57-
"${SOURCE_DIR}/include/native/windows"
58-
)
59-
set(DXVK_NATIVE_D3D9_LIB ${BINARY_DIR}/src/d3d9/libdxvk_d3d9.so)
60-
include_directories("${DXVK_NATIVE_INCLUDE_DIRS}")
61-
ADD_CUSTOM_TARGET(dependencies ALL DEPENDS dxvk-native)
62-
endif()
63-
6448
### Define library ALIASes for use without CONAN_PKG:: prefix
6549
foreach (conan_target ${CONAN_TARGETS})
6650
string(REPLACE "CONAN_PKG::" "" unprefixed_target ${conan_target})

cmake/linux.cmake

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
if(STORM_USE_CONAN_SDL)
2+
set(SDL2_LIBRARIES "sdl")
3+
else()
4+
find_package(SDL2 REQUIRED)
5+
message(STATUS "SDL2_LIBRARIES="${SDL2_LIBRARIES})
6+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${SDL2_INCLUDE_DIRS} -fsigned-char")
7+
message(STATUS "CMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS})
8+
endif()
9+
10+
message("Using DXVK-native for D3D9 API")
11+
12+
include(ExternalProject)
13+
ExternalProject_Add(dxvk-native
14+
GIT_REPOSITORY https://github.com/Joshua-Ashton/dxvk-native
15+
GIT_TAG a2dc99c407340432d4ba5bfa29efa685c27942ea
16+
GIT_SHALLOW ON
17+
BUILD_ALWAYS OFF
18+
CONFIGURE_HANDLED_BY_BUILD ON
19+
CONFIGURE_COMMAND meson setup ../dxvk-native --buildtype=release -Denable_d3d11=false -Denable_d3d10=false -Denable_dxgi=false
20+
BUILD_COMMAND ninja
21+
INSTALL_COMMAND ""
22+
)
23+
ExternalProject_Get_property(dxvk-native SOURCE_DIR BINARY_DIR)
24+
set(DXVK_NATIVE_INCLUDE_DIRS
25+
"${SOURCE_DIR}/include/native/directx"
26+
"${SOURCE_DIR}/include/native/windows"
27+
)
28+
set(NATIVE_D3D9_LIBS ${BINARY_DIR}/src/d3d9/libdxvk_d3d9.so)
29+
include_directories("${DXVK_NATIVE_INCLUDE_DIRS}")
30+
add_custom_target(dependencies ALL DEPENDS dxvk-native)

conanfile.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ class StormEngine(ConanFile):
1111
"output_directory": "ANY",
1212
"watermark_file": "ANY",
1313
"crash_reports": [True, False],
14-
"steam": [True, False]
14+
"steam": [True, False],
15+
"conan_sdl": [True, False]
1516
}
1617

1718
# dependencies used in deploy binaries
1819
# conan-center
19-
requires = ["zlib/1.2.11", "spdlog/1.9.2", "fast_float/3.4.0", "sdl/2.0.18", "mimalloc/2.0.3", "sentry-native/0.5.0",
20+
requires = ["zlib/1.2.11", "spdlog/1.9.2", "fast_float/3.4.0", "mimalloc/2.0.3", "sentry-native/0.5.0",
2021
# storm.jfrog.io
2122
"directx/9.0@storm/prebuilt", "fmod/2.02.05@storm/prebuilt"]
2223
# aux dependencies (e.g. for tests)
@@ -34,6 +35,8 @@ def requirements(self):
3435
self.options["libsndfile"].with_mpeg= False #fix for 0a12560440ac9f760670829a1cde44b787f587ad/src/src/libmpg123/mpg123lib_intern.h:346: undefined reference to `__pow_finite'
3536
if self.options.steam:
3637
self.requires("steamworks/1.5.1@storm/prebuilt")
38+
if self.options.conan_sdl:
39+
self.requires("sdl/2.0.18")
3740

3841
generators = "cmake_multi"
3942

src/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,8 @@ else()
5050
add_compile_options(-v)
5151
add_link_options(-v)
5252

53-
# Always generate debug information
54-
add_compile_options(-g)
55-
add_link_options(-g)
53+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3")
54+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g")
5655

5756
# Add _DEBUG flag
5857
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")

src/apps/engine/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ STORM_SETUP(
3232
# external
3333
mimalloc
3434
sentry-native
35-
sdl
35+
${SDL2_LIBRARIES}
3636
zlib
3737

3838
# system
3939
${SYSTEM_DEPS}
40-
)
40+
)

src/libs/core/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
STORM_SETUP(
22
TARGET_NAME core
33
TYPE library
4-
DEPENDENCIES diagnostics math shared_headers steam_api fast_float sdl window
5-
)
4+
DEPENDENCIES diagnostics math shared_headers steam_api fast_float ${SDL2_LIBRARIES} window
5+
)

src/libs/input/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
STORM_SETUP(
22
TARGET_NAME input
33
TYPE library
4-
DEPENDENCIES sdl util
5-
)
4+
DEPENDENCIES ${SDL2_LIBRARIES} util
5+
)

src/libs/renderer/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
if (WIN32)
22
set(SYSTEM_DEPS "legacy_stdio_definitions")
33
else()
4-
set(SYSTEM_DEPS "${DXVK_NATIVE_D3D9_LIB}")
4+
set(SYSTEM_DEPS "${NATIVE_D3D9_LIBS}")
55
endif()
66

77
STORM_SETUP(
88
TARGET_NAME renderer
99
TYPE storm_module
1010
DEPENDENCIES core directx util ${SYSTEM_DEPS}
11-
)
11+
)

src/libs/window/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
STORM_SETUP(
22
TARGET_NAME window
33
TYPE library
4-
DEPENDENCIES sdl
5-
)
4+
DEPENDENCIES ${SDL2_LIBRARIES}
5+
)

0 commit comments

Comments
 (0)