Update following cmake_common changes.

This commit is contained in:
Mikaël Capelle
2022-04-19 23:33:31 +02:00
parent 525b14359f
commit 4f6f02234f
3 changed files with 67 additions and 59 deletions
+6 -51
View File
@@ -1,60 +1,15 @@
# CMake 3.18 due to https://gitlab.kitware.com/cmake/cmake/-/issues/20764
cmake_minimum_required(VERSION 3.18)
if(DEFINED DEPENDENCIES_DIR)
include(${DEPENDENCIES_DIR}/modorganizer_super/cmake_common/mo2.cmake)
else()
include(${CMAKE_CURRENT_LIST_DIR}/../cmake_common/mo2.cmake)
endif()
# set globally as Nuget gets confused about ZERO_CHECK, ALL_BUILD and INSTALL otherwise
set(CMAKE_DOTNET_TARGET_FRAMEWORK_VERSION "v4.8")
project(installer_omod LANGUAGES CXX CSharp)
set(project_type plugin)
set(enable_warnings OFF)
# Dummy .NET library as VS_PACKAGE_REFERENCES doesn't work on C++/CLI projects yet
# Needs to be declared before cmake_common stuff is included as that polutes the environment and makes C# get compiled as C++
# This only mostly works - you need to build via Visual Studio or run `msbuild -t:restore installer_omod.sln` at least once before this will build via the command line due to https://gitlab.kitware.com/cmake/cmake/-/issues/20646
add_library(dummy_cs_project SHARED DummyCSFile.cs)
set_target_properties(dummy_cs_project PROPERTIES
LINKER_LANGUAGE CSharp
VS_PACKAGE_REFERENCES "OMODFramework_2.2.2;OMODFramework.Scripting_2.2.2;RtfPipe_1.0.7388.1242"
)
if(DEFINED DEPENDENCIES_DIR)
include(${DEPENDENCIES_DIR}/modorganizer_super/cmake_common/project.cmake)
else()
include(../cmake_common/project.cmake)
endif()
add_subdirectory(src)
# Ideally we'd use "$<TARGET_FILE_DIR:dummy_cs_project>", but the relevant property doesn't support generator expressions.
set(omod_framework_prefix "${CMAKE_BINARY_DIR}/$(Configuration)" CACHE PATH "Path where OMODFramework.dll and OMODFramework.Scripting.dll can be found. The default value is where the nuget package artifacts will end up. Override if you want to use a custom build.")
set_target_properties(${PROJECT_NAME} PROPERTIES
COMMON_LANGUAGE_RUNTIME ""
# latest doesn't work with CLR
CXX_STANDARD 17
#DOTNET_TARGET_FRAMEWORK "netstandard2.0"
VS_DOTNET_REFERENCE_OMODFramework "${omod_framework_prefix}/OMODFramework.dll"
VS_DOTNET_REFERENCE_OMODFramework.Scripting "${omod_framework_prefix}/OMODFramework.Scripting.dll"
VS_DOTNET_REFERENCE_RtfPipe "${CMAKE_BINARY_DIR}/$(Configuration)/RtfPipe.dll"
VS_DOTNET_REFERENCES "System.dll;System.Core.dll"
)
# C++/CLI doesn't support two-phase lookup yet
target_compile_options(${PROJECT_NAME} PRIVATE "/Zc:twoPhase-")
# OMODFramework and OMODFramework.Scripting reference different .NET standard libraries. This generates warnings when using them together.
target_compile_options(${PROJECT_NAME} PRIVATE "/wd4691")
# We don't want ERROR defined
target_compile_definitions(${PROJECT_NAME} PRIVATE "NOGDI")
# We don't need to actually link with dummy_cs_project, especially as its dependencies aren't pulled in. We do need it to build first, though.
add_dependencies(${PROJECT_NAME} dummy_cs_project)
install(FILES "$<TARGET_FILE_DIR:${PROJECT_NAME}>/OMODFramework.dll" DESTINATION "${install_dir}/data")
install(FILES "$<TARGET_FILE_DIR:${PROJECT_NAME}>/OMODFramework.Scripting.dll" DESTINATION "${install_dir}/data")
install(FILES "$<TARGET_FILE_DIR:${PROJECT_NAME}>/ICSharpCode.SharpZipLib.dll" DESTINATION "${install_dir}/data")
install(FILES "$<TARGET_FILE_DIR:${PROJECT_NAME}>/System.Drawing.Common.dll" DESTINATION "${install_dir}/data")
install(FILES "$<TARGET_FILE_DIR:${PROJECT_NAME}>/RtfPipe.dll" DESTINATION "${install_dir}/data")
install(FILES "$<TARGET_PDB_FILE_DIR:${PROJECT_NAME}>/ICSharpCode.SharpZipLib.pdb" DESTINATION pdb)
# Other PDB files get downloaded by Visual Studio during debugging when https://symbols.nuget.org/download/symbols is in the symbol server list
+61 -8
View File
@@ -1,12 +1,65 @@
cmake_minimum_required(VERSION 3.16)
if(DEFINED DEPENDENCIES_DIR)
include(${DEPENDENCIES_DIR}/modorganizer_super/cmake_common/src.cmake)
else()
include(../../cmake_common/src.cmake)
endif()
requires_project(game_features)
# Dummy .NET library as VS_PACKAGE_REFERENCES doesn't work on C++/CLI projects yet
# Needs to be declared before cmake_common stuff is included as that polutes the environment and makes C# get compiled as C++
# This only mostly works - you need to build via Visual Studio or run `msbuild -t:restore installer_omod.sln` at least once before this will build via the command line due to https://gitlab.kitware.com/cmake/cmake/-/issues/20646
add_library(dummy_cs_project SHARED DummyCSFile.cs)
set_target_properties(dummy_cs_project PROPERTIES
LINKER_LANGUAGE CSharp
VS_PACKAGE_REFERENCES "OMODFramework_2.2.2;OMODFramework.Scripting_2.2.2;RtfPipe_1.0.7388.1242"
)
# I'd like to use get_target_property(source_files ${PROJECT_NAME} SOURCES) as globbing is naughty, but need to filter out the things that aren't relative to this directory.
add_library(installer_omod SHARED)
mo2_configure_plugin(installer_omod WARNINGS OFF CLI ON)
# I'd like to use get_target_property(source_files ${PROJECT_NAME} SOURCES) as
# globbing is naughty, but need to filter out the things that aren't relative to this directory.
file(GLOB_RECURSE source_files CONFIGURE_DEPENDS *.cpp;*.h;*.ui)
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX src FILES ${source_files})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX src FILES ${source_files})
# Ideally we'd use "$<TARGET_FILE_DIR:dummy_cs_project>", but the relevant property
# doesn't support generator expressions.
set(omod_framework_prefix "${CMAKE_BINARY_DIR}/$(Configuration)"
CACHE PATH "Path where OMODFramework.dll and OMODFramework.Scripting.dll can be found. The default value is where the nuget package artifacts will end up. Override if you want to use a custom build.")
set_target_properties(${PROJECT_NAME} PROPERTIES
COMMON_LANGUAGE_RUNTIME ""
# latest doesn't work with CLR
CXX_STANDARD 17
#DOTNET_TARGET_FRAMEWORK "netstandard2.0"
VS_DOTNET_REFERENCE_OMODFramework "${omod_framework_prefix}/OMODFramework.dll"
VS_DOTNET_REFERENCE_OMODFramework.Scripting "${omod_framework_prefix}/OMODFramework.Scripting.dll"
VS_DOTNET_REFERENCE_RtfPipe "${CMAKE_BINARY_DIR}/$(Configuration)/RtfPipe.dll"
VS_DOTNET_REFERENCES "System.dll;System.Core.dll"
)
target_compile_options(
installer_omod
PRIVATE
# C++/CLI doesn't support two-phase lookup yet
"/Zc:twoPhase-"
# OMODFramework and OMODFramework.Scripting reference different .NET standard libraries. This generates warnings when using them together.
"/wd4691")
# We don't want ERROR defined
target_compile_definitions(installer_omod PRIVATE "NOGDI")
# We don't need to actually link with dummy_cs_project, especially as its dependencies
# aren't pulled in. We do need it to build first, though.
add_dependencies(installer_omod dummy_cs_project)
mo2_install_target(installer_omod)
install(
FILES
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/OMODFramework.dll"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/OMODFramework.Scripting.dll"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/ICSharpCode.SharpZipLib.dll"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/System.Drawing.Common.dll"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/RtfPipe.dll"
DESTINATION "${MO2_INSTALL_PATH}/bin/plugins/data"
)
install(
FILES "$<TARGET_PDB_FILE_DIR:${PROJECT_NAME}>/ICSharpCode.SharpZipLib.pdb"
DESTINATION pdb)
# Other PDB files get downloaded by Visual Studio during debugging when https://symbols.nuget.org/download/symbols is in the symbol server list