mirror of
https://github.com/Neo-Desktop/WindowsXPKg
synced 2024-12-22 20:40:16 +02:00
Revert to old CMakeLists for now
This commit is contained in:
parent
9f7920ca2d
commit
11253c5e2c
234
CMakeLists.txt
234
CMakeLists.txt
@ -18,142 +18,160 @@
|
|||||||
# @FileCreated by Andrew on 05/30/2023
|
# @FileCreated by Andrew on 05/30/2023
|
||||||
# @Maintainer Neo
|
# @Maintainer Neo
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.12)
|
CMAKE_MINIMUM_REQUIRED(VERSION 3.12)
|
||||||
|
PROJECT(UMSKT)
|
||||||
|
SET(CMAKE_CXX_STANDARD 17)
|
||||||
|
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
|
OPTION(UMSKT_USE_SHARED_OPENSSL "Force linking against the system-wide OpenSSL library" OFF)
|
||||||
|
OPTION(MUSL_STATIC "Enable fully static builds in a muslc environment (i.e. Alpine Linux)" OFF)
|
||||||
|
OPTION(DJGPP_WATT32 "Enable compilation and linking with DJGPP/WATT32/OpenSSL" OFF)
|
||||||
|
OPTION(MSVC_MSDOS_STUB "Specify a custom MS-DOS stub for a 32-bit MSVC compilation" OFF)
|
||||||
|
|
||||||
project(UMSKT)
|
SET(UMSKT_LINK_LIBS ${UMSKT_LINK_LIBS})
|
||||||
set(CMAKE_OSX_SYSROOT "macosx" CACHE PATH "macOS SDK path")
|
SET(UMSKT_LINK_DIRS ${UMSKT_LINK_DIRS})
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
IF(UMSKT_USE_SHARED_OPENSSL)
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
SET(OPENSSL_USE_STATIC_LIBS FALSE)
|
||||||
|
SET(OPENSSL_MSVC_STATIC_RT FALSE)
|
||||||
|
MESSAGE(WARNING "[UMSKT] Forcing shared OpenSSL runtime")
|
||||||
|
ELSE()
|
||||||
|
SET(OPENSSL_USE_STATIC_LIBS TRUE)
|
||||||
|
SET(OPENSSL_MSVC_STATIC_RT TRUE)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
option(UMSKT_USE_SHARED_OPENSSL "Force linking against the system-wide OpenSSL library" OFF)
|
IF(DJGPP_WATT32)
|
||||||
option(MUSL_STATIC "Enable fully static builds in a muslc environment (i.e. Alpine Linux)" OFF)
|
SET(CMAKE_SYSTEM_NAME MSDOS)
|
||||||
option(DJGPP_WATT32 "Enable compilation and linking with DJGPP/WATT32/OpenSSL" OFF)
|
SET(UMSKT_LINK_LIBS ${UMSKT_LINK_LIBS} ${DJGPP_WATT32})
|
||||||
option(MSVC_MSDOS_STUB "Specify a custom MS-DOS stub for a 32-bit MSVC compilation" OFF)
|
SET(UMSKT_LINK_DIRS ${UMSKT_LINK_DIRS} ${WATT_ROOT}/lib)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
find_package(OpenSSL REQUIRED)
|
# find the system installed OpenSSL development library
|
||||||
|
FIND_PACKAGE(OpenSSL REQUIRED)
|
||||||
if(NOT OpenSSL_FOUND)
|
IF(NOT OPENSSL_FOUND)
|
||||||
message(FATAL_ERROR "OpenSSL Development Libraries Not Found. Please install the required OpenSSL development package.")
|
MESSAGE(SEND_ERROR "OpenSSL Development Libraries Not Found")
|
||||||
endif()
|
MESSAGE(SEND_ERROR "Please consult your package manager of choice to install the prerequisite")
|
||||||
|
MESSAGE(SEND_ERROR "The package name is commonly called libssl-dev or openssl-dev depending on distribution")
|
||||||
if(UMSKT_USE_SHARED_OPENSSL)
|
MESSAGE(FATAL_ERROR "Can not continue without OpenSSL")
|
||||||
set(OPENSSL_USE_STATIC_LIBS FALSE)
|
ENDIF()
|
||||||
set(OPENSSL_MSVC_STATIC_RT FALSE)
|
|
||||||
else()
|
|
||||||
set(OPENSSL_USE_STATIC_LIBS TRUE)
|
|
||||||
set(OPENSSL_MSVC_STATIC_RT TRUE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# if we found shared libraries - do the following:
|
# if we found shared libraries - do the following:
|
||||||
string(REGEX MATCH "(\\.so|\\.dll|\\.dylib)$" OPENSSL_CRYPTO_SHARED "${OPENSSL_CRYPTO_LIBRARY}")
|
STRING(REGEX MATCH "(\\.so|\\.dll|\\.dylib)$" OPENSSL_CRYPTO_SHARED "${OPENSSL_CRYPTO_LIBRARY}")
|
||||||
if(OPENSSL_CRYPTO_SHARED)
|
IF(OPENSSL_CRYPTO_SHARED)
|
||||||
message(STATUS "[UMSKT] Detected Shared library version of OpenSSL")
|
MESSAGE(STATUS "[UMSKT] Detected Shared library version of OpenSSL")
|
||||||
set(BUILD_SHARED_LIBS ON)
|
SET(BUILD_SHARED_LIBS ON)
|
||||||
else()
|
ELSE()
|
||||||
message(STATUS "[UMSKT] Detected Static Library version of OpenSSL")
|
MESSAGE(STATUS "[UMSKT] Detected Static Library version of OpenSSL")
|
||||||
endif()
|
ENDIF()
|
||||||
|
|
||||||
# if we're compiling with MSVC, respect the DEBUG compile option
|
# if we're compiling with MSVC, respect the DEBUG compile option
|
||||||
if(MSVC)
|
IF(MSVC)
|
||||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
SET(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||||
if(NOT BUILD_SHARED_LIBS)
|
IF(NOT BUILD_SHARED_LIBS)
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "/MT")
|
SET(CMAKE_CXX_FLAGS_RELEASE "/MT")
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "/MTd")
|
SET(CMAKE_CXX_FLAGS_DEBUG "/MTd")
|
||||||
else()
|
ELSE()
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "/MD")
|
SET(CMAKE_CXX_FLAGS_RELEASE "/MD")
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "/MDd")
|
SET(CMAKE_CXX_FLAGS_DEBUG "/MDd")
|
||||||
endif()
|
ENDIF()
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "/INCREMENTAL:NO /NODEFAULTLIB:MSVCRT")
|
SET(CMAKE_EXE_LINKER_FLAGS "/INCREMENTAL:NO /NODEFAULTLIB:MSVCRT")
|
||||||
set(CMAKE_ENABLE_EXPORTS ON)
|
SET(CMAKE_ENABLE_EXPORTS ON)
|
||||||
set(UMSKT_EXE_WINDOWS_EXTRA src/windows/umskt.rc)
|
SET(UMSKT_EXE_WINDOWS_EXTRA src/windows/umskt.rc)
|
||||||
set(UMSKT_EXE_WINDOWS_DLL src/windows/dllmain.cpp)
|
SET(UMSKT_EXE_WINDOWS_DLL src/windows/dllmain.cpp)
|
||||||
endif()
|
ENDIF()
|
||||||
|
|
||||||
if(MUSL_STATIC AND NOT UMSKT_USE_SHARED_OPENSSL)
|
IF(MUSL_STATIC)
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++")
|
MESSAGE(STATUS "[UMSKT] Performing a fully static build using muslc")
|
||||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc -static-libstdc++")
|
SET(CMAKE_EXE_LINKER_FLAGS "-static -static-libgcc -static-libstdc++")
|
||||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
SET(CMAKE_SHARED_LINKER_FLAGS "-static -static-libgcc -static-libstdc++")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc -static-libstdc++")
|
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc -static-libstdc++")
|
||||||
endif()
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
include(cmake/CPM.cmake)
|
# initalize cpm.CMake
|
||||||
|
INCLUDE(cmake/CPM.cmake)
|
||||||
|
|
||||||
|
# fetch cpm.CMake dependencies
|
||||||
|
# Include JSON development library
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME nlohmann_json
|
NAME nlohmann_json
|
||||||
GITHUB_REPOSITORY nlohmann/json
|
GITHUB_REPOSITORY nlohmann/json
|
||||||
VERSION 3.11.2
|
VERSION 3.11.2
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Include fmt development library
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME fmt
|
NAME fmt
|
||||||
GITHUB_REPOSITORY fmtlib/fmt
|
GITHUB_REPOSITORY fmtlib/fmt
|
||||||
GIT_TAG 10.0.0
|
GIT_TAG 10.0.0
|
||||||
VERSION 10.0.0
|
VERSION 10.0.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Include cmrc resource compiler
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME cmrc
|
NAME cmrc
|
||||||
GITHUB_REPOSITORY vector-of-bool/cmrc
|
GITHUB_REPOSITORY vector-of-bool/cmrc
|
||||||
GIT_TAG 2.0.1
|
GIT_TAG 2.0.1
|
||||||
VERSION 2.0.1
|
VERSION 2.0.1
|
||||||
)
|
)
|
||||||
|
|
||||||
# For Emscripten builds, set CMAKE_TOOLCHAIN_FILE to the appropriate file
|
# Include Crypto++ development library
|
||||||
set(EMSCRIPTEN_BUILD OFF CACHE BOOL "Build for Emscripten" FORCE)
|
#CPMAddPackage(
|
||||||
if(EMSCRIPTEN_BUILD)
|
# NAME cryptopp-cmake
|
||||||
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/cmake/Emscripten.cmake" CACHE string "Emscripten toolchain file")
|
# GITHUB_REPOSITORY abdes/cryptopp-cmake
|
||||||
endif()
|
# GIT_TAG CRYPTOPP_8_8_0
|
||||||
|
# VERSION 8.8.0
|
||||||
|
# OPTIONS "CRYPTOPP_BUILD_TESTING OFF"
|
||||||
|
#)
|
||||||
|
|
||||||
cmrc_add_resource_library(umskt-rc ALIAS umskt::rc NAMESPACE umskt keys.json)
|
#include googletest unit testing library
|
||||||
|
#CPMAddPackage(
|
||||||
|
# NAME googletest
|
||||||
|
# GITHUB_REPOSITORY google/googletest
|
||||||
|
# VERSION 1.13.0
|
||||||
|
# OPTIONS "INSTALL_GTEST OFF" "gtest_force_shared_crt"
|
||||||
|
#)
|
||||||
|
|
||||||
set(LIBUMSKT_SRC
|
### Resource compilation
|
||||||
src/libumskt/libumskt.cpp
|
CMRC_ADD_RESOURCE_LIBRARY(umskt-rc ALIAS umskt::rc NAMESPACE umskt keys.json)
|
||||||
src/libumskt/pidgen3/BINK1998.cpp
|
|
||||||
src/libumskt/pidgen3/BINK2002.cpp
|
SET(LIBUMSKT_SRC src/libumskt/libumskt.cpp src/libumskt/pidgen3/BINK1998.cpp src/libumskt/pidgen3/BINK2002.cpp src/libumskt/pidgen3/key.cpp src/libumskt/pidgen3/util.cpp src/libumskt/confid/confid.cpp src/libumskt/pidgen2/PIDGEN2.cpp src/libumskt/debugoutput.cpp)
|
||||||
src/libumskt/pidgen3/key.cpp
|
|
||||||
src/libumskt/pidgen3/util.cpp
|
|
||||||
src/libumskt/confid/confid.cpp
|
|
||||||
src/libumskt/pidgen2/PIDGEN2.cpp
|
|
||||||
src/libumskt/debugoutput.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
#### Separate Build Path for emscripten
|
#### Separate Build Path for emscripten
|
||||||
if (EMSCRIPTEN)
|
IF (EMSCRIPTEN)
|
||||||
add_executable(umskt ${LIBUMSKT_SRC})
|
ADD_EXECUTABLE(umskt ${LIBUMSKT_SRC})
|
||||||
target_include_directories(umskt PUBLIC ${OPENSSL_INCLUDE_DIR})
|
TARGET_INCLUDE_DIRECTORIES(umskt PUBLIC ${OPENSSL_INCLUDE_DIR})
|
||||||
target_link_libraries(umskt -static OpenSSL::Crypto cryptopp::cryptopp fmt)
|
TARGET_LINK_LIBRARIES(umskt -static OpenSSL::Crypto cryptopp::cryptopp fmt)
|
||||||
set(CMAKE_EXECUTABLE_SUFFIX ".html")
|
SET(CMAKE_EXECUTABLE_SUFFIX ".html")
|
||||||
|
|
||||||
set_target_properties(umskt PROPERTIES COMPILE_FLAGS "-Os -sEXPORTED_RUNTIME_METHODS=ccall,cwrap")
|
SET_TARGET_PROPERTIES(umskt PROPERTIES COMPILE_FLAGS "-Os -sEXPORTED_RUNTIME_METHODS=ccall,cwrap")
|
||||||
set_target_properties(umskt PROPERTIES LINK_FLAGS "-Os -sWASM=1 -sEXPORT_ALL=1 -sEXPORTED_RUNTIME_METHODS=ccall,cwrap --no-entry")
|
SET_TARGET_PROPERTIES(umskt PROPERTIES LINK_FLAGS "-Os -sWASM=1 -sEXPORT_ALL=1 -sEXPORTED_RUNTIME_METHODS=ccall,cwrap --no-entry")
|
||||||
else()
|
ELSE()
|
||||||
if(NOT UMSKT_USE_SHARED_OPENSSL)
|
IF(NOT UMSKT_USE_SHARED_OPENSSL)
|
||||||
### Static library compilation
|
### Static library compilation
|
||||||
add_library(_umskt STATIC ${LIBUMSKT_SRC})
|
ADD_LIBRARY(_umskt STATIC ${LIBUMSKT_SRC})
|
||||||
target_include_directories(_umskt PUBLIC ${OPENSSL_INCLUDE_DIR})
|
TARGET_INCLUDE_DIRECTORIES(_umskt PUBLIC ${OPENSSL_INCLUDE_DIR})
|
||||||
target_link_libraries(_umskt -static OpenSSL::Crypto fmt ${UMSKT_LINK_LIBS})
|
TARGET_LINK_LIBRARIES(_umskt -static OpenSSL::Crypto fmt ${UMSKT_LINK_LIBS})
|
||||||
else()
|
ELSE()
|
||||||
### Shared library compilation
|
### Shared library compilation
|
||||||
add_library(_umskt SHARED ${LIBUMSKT_SRC} ${UMSKT_EXE_WINDOWS_EXTRA} ${UMSKT_EXE_WINDOWS_DLL})
|
ADD_LIBRARY(_umskt SHARED ${LIBUMSKT_SRC} ${UMSKT_EXE_WINDOWS_EXTRA} ${UMSKT_EXE_WINDOWS_DLL})
|
||||||
target_include_directories(_umskt PUBLIC ${OPENSSL_INCLUDE_DIR})
|
TARGET_INCLUDE_DIRECTORIES(_umskt PUBLIC ${OPENSSL_INCLUDE_DIR})
|
||||||
target_link_libraries(_umskt OpenSSL::Crypto fmt ${UMSKT_LINK_LIBS})
|
TARGET_LINK_LIBRARIES(_umskt OpenSSL::Crypto fmt ${UMSKT_LINK_LIBS})
|
||||||
target_link_directories(_umskt PUBLIC ${UMSKT_LINK_DIRS})
|
TARGET_LINK_DIRECTORIES(_umskt PUBLIC ${UMSKT_LINK_DIRS})
|
||||||
endif()
|
ENDIF()
|
||||||
|
|
||||||
### UMSKT executable compilation
|
### UMSKT executable compilation
|
||||||
add_executable(umskt src/main.cpp src/cli.cpp ${UMSKT_EXE_WINDOWS_EXTRA})
|
ADD_EXECUTABLE(umskt src/main.cpp src/cli.cpp ${UMSKT_EXE_WINDOWS_EXTRA})
|
||||||
target_include_directories(umskt PUBLIC ${OPENSSL_INCLUDE_DIR})
|
TARGET_INCLUDE_DIRECTORIES(umskt PUBLIC ${OPENSSL_INCLUDE_DIR})
|
||||||
target_link_libraries(umskt _umskt OpenSSL::Crypto fmt nlohmann_json::nlohmann_json umskt::rc ${UMSKT_LINK_LIBS})
|
TARGET_LINK_LIBRARIES(umskt _umskt OpenSSL::Crypto fmt nlohmann_json::nlohmann_json umskt::rc ${UMSKT_LINK_LIBS})
|
||||||
target_link_directories(umskt PUBLIC ${UMSKT_LINK_DIRS})
|
TARGET_LINK_DIRECTORIES(umskt PUBLIC ${UMSKT_LINK_DIRS})
|
||||||
if(MSVC AND MSVC_MSDOS_STUB)
|
IF(MSVC AND MSVC_MSDOS_STUB)
|
||||||
set_property(TARGET umskt APPEND PROPERTY LINK_FLAGS /STUB:${MSVC_MSDOS_STUB})
|
SET_PROPERTY(TARGET umskt APPEND PROPERTY LINK_FLAGS /STUB:${MSVC_MSDOS_STUB})
|
||||||
endif()
|
ENDIF()
|
||||||
|
|
||||||
### Copy Shared Libraries and dependency files
|
### Copy Shared Libraries and dependency files
|
||||||
if (OPENSSL_CRYPTO_SHARED)
|
IF (OPENSSL_CRYPTO_SHARED)
|
||||||
get_filename_component(OPENSSL_CRYPTO_LIBRARY_FILENAME ${OPENSSL_CRYPTO_LIBRARY} NAME)
|
GET_FILENAME_COMPONENT(OPENSSL_CRYPTO_LIBRARY_FILENAME ${OPENSSL_CRYPTO_LIBRARY} NAME)
|
||||||
configure_file(${OPENSSL_CRYPTO_LIBRARY} "${CMAKE_CURRENT_BINARY_DIR}/${OPENSSL_CRYPTO_LIBRARY_FILENAME}" COPYONLY)
|
CONFIGURE_FILE(${OPENSSL_CRYPTO_LIBRARY} "${CMAKE_CURRENT_BINARY_DIR}/${OPENSSL_CRYPTO_LIBRARY_FILENAME}" COPYONLY)
|
||||||
endif()
|
ENDIF()
|
||||||
endif()
|
ENDIF()
|
||||||
|
Loading…
Reference in New Issue
Block a user