chore: update CMake build script but not tested

This commit is contained in:
2024-07-24 18:12:49 +08:00
parent ecebc42603
commit a1de143ae8
6 changed files with 148 additions and 67 deletions

View File

@@ -1,24 +0,0 @@
# Check Windows platform
if (NOT WIN32)
message(FATAL_ERROR "VirtoolsSchematicWeaver::Materializer only supports Windows platform.")
endif ()
# Check MSVC toolchain
if (NOT MSVC)
message(FATAL_ERROR "VirtoolsSchematicWeaver::Materializer only supports MSVC build toolchain.")
endif ()
# Check architecture
if (NOT CMAKE_SIZEOF_VOID_P EQUAL 4)
message(FATAL_ERROR "VirtoolsSchematicWeaver::Materializer only supports 32-bit platform.")
endif ()
# Check build type
set(VSW_MATERIALIZER_BUILD_TYPES
"plugin" "standalone"
)
if (VSW_MATERIALIZER_BUILD_TYPE IN_LIST VSW_MATERIALIZER_BUILD_TYPES)
message( "VirtoolsSchematicWeaver::Materializer build type: ${VSW_MATERIALIZER_BUILD_TYPE}")
else ()
message(FATAL_ERROR
"VirtoolsSchematicWeaver::Materializer do not have correct type."
"Please assign a legal value (\"plugin\" or \"standalone\") to VSW_MATERIALIZER_BUILD_TYPE."
)
endif ()

View File

@@ -0,0 +1,27 @@
if (WIN32)
# In Windows, we use custom way to import SQLite
# Check variables# Check YYCC path variable
if (NOT DEFINED SQLITE_AMALGAMATION_PATH)
message(FATAL_ERROR "You must set SQLITE_AMALGAMATION_PATH variable to the header of SQLite library.")
endif()
if (NOT DEFINED SQLITE_DLL_PATH)
message(FATAL_ERROR "You must set SQLITE_DLL_PATH variable the directory containing generated linking LIB file.")
endif()
# Add imported library
add_library(SQLite3 INTERFACE IMPORTED)
add_library(SQLite3::SQLite3 ALIAS SQLite3)
# Setup header files
set_target_properties(VirtoolsSDK PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES
"${SQLITE_AMALGAMATION_PATH}"
)
# Setup lib files
set_target_properties(VirtoolsSDK PROPERTIES
INTERFACE_LINK_LIBRARIES
"${SQLITE_DLL_PATH}/sqlite3.lib"
)
else ()
# In non-Windows, we import SQLite from CMake
find_package(SQLite3 REQUIRED)
endif ()

View File

@@ -1,35 +0,0 @@
# ========== Check Variables ==========
# Check Virtools version variable
set(SPECIAL_VIRTOOLS_VERSIONS
"21"
)
set(LEGACY_VIRTOOLS_VERSIONS
"25"
"30"
"35"
"40"
"50"
)
if (VIRTOOLS_VERSION IN_LIST SPECIAL_VIRTOOLS_VERSIONS)
message(
"Specified Virtools version: ${VIRTOOLS_VERSION}."
"Please note in this verions, your provided Virtools root path must be the root of GitHub repository: doyaGu/Virtools-SDK-2.1"
)
elseif (VIRTOOLS_VERSION IN_LIST LEGACY_VIRTOOLS_VERSIONS)
message("Specified Virtools version: ${VIRTOOLS_VERSION}.")
else ()
message(FATAL_ERROR
"You must set VIRTOOLS_VERSION variable to specify the version of your target Virtools before configurating this project."
"The valid Virtools version are 21, 25, 30, 35, 40, 50."
)
endif ()
# Check Virtools path variable
if (NOT DEFINED VIRTOOLS_PATH)
message(FATAL_ERROR
"You must set VIRTOOLS_PATH variable to specify the root folder of Virtools before configurating this project."
"Please note this path is different when you picking Virtools 2.1 version."
)
endif()
# ========== Import library ==========

View File

@@ -1,4 +1,3 @@
# Check YYCC path variable
if (NOT DEFINED YYCC_PATH)
message(FATAL_ERROR "You must set YYCC_PATH variable to one of CMake distribution of YYCC installation path.")

View File

@@ -0,0 +1,116 @@
# ========== Check Basic Environment ==========
# Check Windows platform
if (NOT WIN32)
message(FATAL_ERROR "VirtoolsSchematicWeaver::Materializer only supports Windows platform.")
endif ()
# Check MSVC toolchain
if (NOT MSVC)
message(FATAL_ERROR "VirtoolsSchematicWeaver::Materializer only supports MSVC build toolchain.")
endif ()
# Check architecture
if (NOT CMAKE_SIZEOF_VOID_P EQUAL 4)
message(FATAL_ERROR "VirtoolsSchematicWeaver::Materializer only supports 32-bit platform.")
endif ()
# ========== Check Materializer Variables ==========
# Check build type
set(MATERIALIZER_BUILD_TYPES
"plugin" "standalone"
)
if (MATERIALIZER_BUILD_TYPE IN_LIST MATERIALIZER_BUILD_TYPES)
message( "VirtoolsSchematicWeaver::Materializer build type: ${MATERIALIZER_BUILD_TYPE}")
else ()
message(FATAL_ERROR
"VirtoolsSchematicWeaver::Materializer do not have correct type."
"Please assign a legal value (\"plugin\" or \"standalone\") to MATERIALIZER_BUILD_TYPE."
)
endif ()
# ========== Check Virtools Variables ==========
# Check Virtools version variable
set(VIRTOOLS_VERSIONS "21" "25" "30" "35" "40" "50")
if (VIRTOOLS_VERSION IN_LIST VIRTOOLS_VERSIONS)
message("Specified Virtools version: ${VIRTOOLS_VERSION}.")
else ()
message(FATAL_ERROR
"You must set VIRTOOLS_VERSION variable to specify the version of your target Virtools before configurating this project."
"The valid Virtools version are 21, 25, 30, 35, 40, 50."
)
endif ()
# Check Virtools path variable
if (NOT DEFINED VIRTOOLS_PATH)
message(FATAL_ERROR
"You must set VIRTOOLS_PATH variable to specify the root folder of Virtools before configurating this project."
"Please note this path is different when you picking Virtools 2.1 version."
)
endif()
# Check the combination between materializer build type and Virtools version
set(STANDALONE_MATERIALIZER_SUPPORTED_VT "21" "25" "30" "35" "40" "50")
set(PLUGIN_MATERIALIZER_SUPPORTED_VT "30" "35" "40" "50")
if (MATERIALIZER_BUILD_TYPE STREQUAL "plugin")
if (NOT (VIRTOOLS_VERSION IN_LIST PLUGIN_MATERIALIZER_SUPPORTED_VT))
message(FATAL_ERROR
"The combination between build type ${MATERIALIZER_BUILD_TYPE} and Virtools version ${VIRTOOLS_VERSION} is not compatible."
"Please view our README for a legal combination."
)
endif ()
else ()
if (NOT (VIRTOOLS_VERSION IN_LIST STANDALONE_MATERIALIZER_SUPPORTED_VT))
message(FATAL_ERROR
"The combination between build type ${MATERIALIZER_BUILD_TYPE} and Virtools version ${VIRTOOLS_VERSION} is not compatible."
"Please view our README for a legal combination."
)
endif ()
endif ()
# ========== Import library ==========
# Build essential variables
# Virtools header path
if (VIRTOOLS_VERSION STREQUAL "21")
set(VIRTOOLS_HEADER_PATH ${VIRTOOLS_PATH}/Include) # 2.1
elseif (VIRTOOLS_VERSION STREQUAL "25")
set(VIRTOOLS_HEADER_PATH ${VIRTOOLS_PATH}/Virtools_SDK/Includes) # 2.5
else ()
set(VIRTOOLS_HEADER_PATH ${VIRTOOLS_PATH}/Sdk/Includes) # 3.0, 3.5, 4.0, 5.0
endif ()
# Virtools lib path
if (VIRTOOLS_VERSION STREQUAL "21")
set(VIRTOOLS_LIB_PATH ${VIRTOOLS_PATH}/Lib) # 2.1
elseif (VIRTOOLS_VERSION STREQUAL "25")
set(VIRTOOLS_LIB_PATH ${VIRTOOLS_PATH}/Virtools_SDK/Lib) # 2.5
elseif (VIRTOOLS_VERSION STREQUAL "30")
set(VIRTOOLS_LIB_PATH ${VIRTOOLS_PATH}/Sdk/Lib) # 3.0
else ()
set(VIRTOOLS_LIB_PATH ${VIRTOOLS_PATH}/Sdk/Lib/Win32/Release) # 3.5, 4.0, 5.0
endif ()
# Real importer
add_library(VirtoolsSDK INTERFACE IMPORTED)
# Setup header files
set_target_properties(VirtoolsSDK PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES
"${VIRTOOLS_HEADER_PATH}"
)
# Setup lib files
set_target_properties(VirtoolsSDK PROPERTIES
INTERFACE_LINK_LIBRARIES
# Both standalone and plugin build type needed
"${VIRTOOLS_LIB_PATH}/CK2.lib"
"${VIRTOOLS_LIB_PATH}/VxMath.lib"
# Pugin build type only libraries
"$<$<STREQUAL:${MATERIALIZER_BUILD_TYPE},plugin>:${VIRTOOLS_LIB_PATH}/DllEditor.lib>"
"$<$<STREQUAL:${MATERIALIZER_BUILD_TYPE},plugin>:${VIRTOOLS_LIB_PATH}/InterfaceControls.lib>"
"$<$<STREQUAL:${MATERIALIZER_BUILD_TYPE},plugin>:${VIRTOOLS_LIB_PATH}/CKControls.lib>"
)
# Setup build macros
set_target_properties(VirtoolsSDK PROPERTIES
INTERFACE_COMPILE_DEFINITIONS
# Virtools version macro
"VIRTOOLS_${VIRTOOLS_VERSION}"
# Virtools 5.0 standalone mode need an extra macro
"$<$<AND:$<STREQUAL:${MATERIALIZER_BUILD_TYPE},plugin>,$<STREQUAL:${VIRTOOLS_VERSION},50>>:VIRTOOLS_USER_SDK"
)