Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[POC] Restore 3rd party dependencies using NuGet for MSVC generator #1624

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 41 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,13 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT XRAY_USE_DEFAULT_CXX_LIB)
endif()
endif()

add_compile_options(-Wno-attributes)
if (APPLE)
add_compile_options(-Wl,-undefined,error)
else()
add_compile_options(-Wl,--no-undefined)
if (NOT MSVC)
add_compile_options(-Wno-attributes)
if (APPLE)
add_compile_options(-Wl,-undefined,error)
else()
add_compile_options(-Wl,--no-undefined)
endif()
endif()

# TODO test
Expand Down Expand Up @@ -229,6 +231,10 @@ add_compile_definitions(
_CPPUNWIND
)

include(restoreFromNuget)
if (CMAKE_GENERATOR MATCHES "Visual Studio")
restore_from_nuget()
endif()
if (NOT WIN32)
find_package(SDL2 REQUIRED)
find_package(OpenGL REQUIRED)
Expand Down Expand Up @@ -263,28 +269,36 @@ option(XRAY_USE_LUAJIT "Use LuaJIT" ON)

add_subdirectory(Externals)

add_compile_options(
-Wall
#-Werror
-Wextra
#-pedantic
-Wno-unknown-pragmas
-Wno-strict-aliasing
-Wno-parentheses
-Wno-unused-label
-Wno-unused-parameter
-Wno-switch
#-Wno-padded
#-Wno-c++98-compat
#-Wno-c++98-compat-pedantic
#-Wno-c++11-compat
#-Wno-c++11-compat-pedantic
#-Wno-c++14-compat
#-Wno-c++14-compat-pedantic
#-Wno-newline-eof
$<$<CXX_COMPILER_ID:GNU>:$<$<COMPILE_LANGUAGE:CXX>:-Wno-class-memaccess>>
$<$<CXX_COMPILER_ID:GNU>:$<$<COMPILE_LANGUAGE:CXX>:-Wno-interference-size>>
)
if (MSVC)
add_compile_options(
/EHa-
/EHsc-
/EHs-
)
else()
add_compile_options(
-Wall
#-Werror
-Wextra
#-pedantic
-Wno-unknown-pragmas
-Wno-strict-aliasing
-Wno-parentheses
-Wno-unused-label
-Wno-unused-parameter
-Wno-switch
#-Wno-padded
#-Wno-c++98-compat
#-Wno-c++98-compat-pedantic
#-Wno-c++11-compat
#-Wno-c++11-compat-pedantic
#-Wno-c++14-compat
#-Wno-c++14-compat-pedantic
#-Wno-newline-eof
$<$<CXX_COMPILER_ID:GNU>:$<$<COMPILE_LANGUAGE:CXX>:-Wno-class-memaccess>>
$<$<CXX_COMPILER_ID:GNU>:$<$<COMPILE_LANGUAGE:CXX>:-Wno-interference-size>>
)
endif()

add_subdirectory(src)
add_subdirectory(res)
Expand Down
3 changes: 2 additions & 1 deletion Externals/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
if (XRAY_USE_LUAJIT)
add_subdirectory(LuaJIT-proj)
else()
find_package(Lua51 REQUIRED)
# TODO: Add Lua51 package
# find_package(Lua51 REQUIRED)
endif()

add_subdirectory(xrLuaFix)
Expand Down
40 changes: 40 additions & 0 deletions cmake/restoreFromNuget.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
function(restore_from_nuget)
message(STATUS "Generator is set to ${CMAKE_GENERATOR} - restoring NuGet dependencies...")
find_program(NUGET nuget)
if(NOT NUGET)
message(FATAL "Cannot find nuget. Please install it using: winget install -e --id Microsoft.NuGet")
endif()
FILE(GLOB_RECURSE NUGET_SOURCES "${CMAKE_SOURCE_DIR}/packages.config")
foreach(config_path IN LISTS NUGET_SOURCES )
message(STATUS "Restoring NuGet dependencies from ${config_path}")
execute_process(COMMAND
${NUGET} restore ${config_path} -SolutionDirectory ${CMAKE_BINARY_DIR}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endforeach()

SET(NUGET_PACKAGES_LOCATION "${CMAKE_BINARY_DIR}/packages")

SET(NUGET_SDL_PACKAGE_LOCATION "${NUGET_PACKAGES_LOCATION}/sdl2.nuget.2.28.5/build/native/")
add_library(SDL2::SDL2 UNKNOWN IMPORTED)
set_target_properties(
SDL2::SDL2 PROPERTIES
IMPORTED_LOCATION "${NUGET_SDL_PACKAGE_LOCATION}/lib/${CMAKE_GENERATOR_PLATFORM}/"
INTERFACE_INCLUDE_DIRECTORIES "${NUGET_SDL_PACKAGE_LOCATION}/include/"
)

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(NUGET_D3DX_BUILD_TYPE "debug")
else()
set(NUGET_D3DX_BUILD_TYPE "release")
endif()
SET(NUGET_D3DX_PACKAGE_LOCATION "${NUGET_PACKAGES_LOCATION}/Microsoft.DXSDK.D3DX.9.29.952.8/build/native/")
add_library(Microsoft::DXSDK::D3DX UNKNOWN IMPORTED)
# TODO: Fix x86
set_target_properties(
Microsoft::DXSDK::D3DX PROPERTIES
IMPORTED_LOCATION "${NUGET_D3DX_PACKAGE_LOCATION}/${NUGET_D3DX_BUILD_TYPE}/bin/${CMAKE_GENERATOR_PLATFORM}/"
IMPORTED_IMPLIB "${NUGET_D3DX_PACKAGE_LOCATION}/${NUGET_D3DX_BUILD_TYPE}/lib/${CMAKE_GENERATOR_PLATFORM}/"
INTERFACE_INCLUDE_DIRECTORIES "${NUGET_D3DX_PACKAGE_LOCATION}/include/"
)
endfunction()
5 changes: 4 additions & 1 deletion src/Layers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ if (WIN32)
add_subdirectory(xrRenderPC_R4)
endif()

add_subdirectory(xrRenderPC_GL)
if (NOT CMAKE_GENERATOR MATCHES "Visual Studio")
# TODO: Add OpenGl library
add_subdirectory(xrRenderPC_GL)
endif()
1 change: 0 additions & 1 deletion src/Layers/xrRenderPC_R1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ add_library(xrRenderPC_R1 SHARED)
target_sources(xrRenderPC_R1 PRIVATE
FStaticRender_Blenders.cpp
FStaticRender.cpp
FStaticRender_DetectSector.cpp
FStaticRender.h
FStaticRender_Loader.cpp
FStaticRender_RenderTarget.cpp
Expand Down
1 change: 1 addition & 0 deletions src/utils/xrLC_Light/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ target_link_libraries(xrLC_Light
xrCDB
zlib
xrLCUtil
Microsoft::DXSDK::D3DX
)

target_compile_definitions(xrLC_Light
Expand Down
Loading