Move to cmake across all platforms (#363)

This commit is contained in:
th-2021 2022-08-05 07:59:19 +02:00 committed by GitHub
commit 1ebca42f46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
63 changed files with 5852 additions and 8906 deletions

View file

@ -1,8 +1,9 @@
project(StormLib)
set(PROJECT_NAME StormLib)
#project(StormLib)
cmake_minimum_required(VERSION 3.10)
set(LIBRARY_NAME storm)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@ -15,6 +16,13 @@ option(STORM_BUILD_TESTS
# "BUILD_TESTING" OFF # Stay coherent with CTest variables
)
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(Source_Files__Windows
src/lzma/C/LzFindMt.c
src/lzma/C/Threads.c
)
endif()
set(SRC_FILES
src/adpcm/adpcm.cpp
src/huffman/huff.cpp
@ -46,6 +54,7 @@ set(SRC_FILES
src/SFileVerify.cpp
src/libtomcrypt/src/pk/rsa/rsa_verify_simple.c
src/libtomcrypt/src/misc/crypt_libc.c
${Source_Files__Windows}
)
if(MSVC)
@ -333,6 +342,76 @@ if(WIN32)
set_target_properties(${LIBRARY_NAME} PROPERTIES OUTPUT_NAME "StormLib")
endif()
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
use_props(${LIBRARY_NAME} "${CMAKE_CONFIGURATION_TYPES}" "${DEFAULT_CXX_PROPS}")
endif()
################################################################################
# Compile definitions
################################################################################
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
target_compile_definitions(${LIBRARY_NAME} PRIVATE
"$<$<CONFIG:Debug>:"
"_DEBUG;"
"_CRT_SECURE_NO_WARNINGS;"
">"
"$<$<CONFIG:Release>:"
"NDEBUG"
">"
WIN32
_LIB
"UNICODE;"
"_UNICODE"
)
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
target_compile_definitions(${LIBRARY_NAME} PRIVATE
"$<$<CONFIG:Debug>:"
"_DEBUG;"
"_CRT_SECURE_NO_WARNINGS;"
">"
"$<$<CONFIG:Release>:"
"NDEBUG;"
">"
"WIN32;"
_LIB
"UNICODE;"
"_UNICODE"
)
endif()
endif()
################################################################################
# MSVC runtime library
################################################################################
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
get_property(MSVC_RUNTIME_LIBRARY_DEFAULT TARGET ${LIBRARY_NAME} PROPERTY MSVC_RUNTIME_LIBRARY)
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
string(CONCAT "MSVC_RUNTIME_LIBRARY_STR"
$<$<CONFIG:Debug>:
MultiThreadedDebug
>
$<$<CONFIG:Release>:
MultiThreaded
>
$<$<NOT:$<OR:$<CONFIG:Debug>,$<CONFIG:Release>>>:${MSVC_RUNTIME_LIBRARY_DEFAULT}>
)
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
string(CONCAT "MSVC_RUNTIME_LIBRARY_STR"
$<$<CONFIG:Debug>:
MultiThreadedDebug
>
$<$<CONFIG:Release>:
MultiThreaded
>
$<$<NOT:$<OR:$<CONFIG:Debug>,$<CONFIG:Release>>>:${MSVC_RUNTIME_LIBRARY_DEFAULT}>
)
endif()
set_target_properties(${LIBRARY_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY ${MSVC_RUNTIME_LIBRARY_STR})
endif()
target_link_libraries(${LIBRARY_NAME} ${LINK_LIBS})
target_compile_definitions(${LIBRARY_NAME} INTERFACE STORMLIB_NO_AUTO_LINK) #CMake will take care of the linking
target_include_directories(${LIBRARY_NAME} PUBLIC src/)