diff options
author | Jan200101 <sentrycraft123@gmail.com> | 2023-09-10 23:54:22 +0200 |
---|---|---|
committer | Jan200101 <sentrycraft123@gmail.com> | 2023-09-10 23:54:22 +0200 |
commit | 13df46ba41efe2d94e3dbec240ff0889ac054eb7 (patch) | |
tree | f76ba0d5e109973429caef5e2001f99c3fdd7a85 /cmake | |
parent | ac01bde6b9673b80dd225be3edebbe2255d9ebd2 (diff) | |
download | SouthRPC-13df46ba41efe2d94e3dbec240ff0889ac054eb7.tar.gz SouthRPC-13df46ba41efe2d94e3dbec240ff0889ac054eb7.zip |
MSVC
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/Findjson-c.cmake | 50 | ||||
-rw-r--r-- | cmake/Findspdlog.cmake | 19 | ||||
-rw-r--r-- | cmake/R2plugin.cmake | 5 | ||||
-rw-r--r-- | cmake/utils.cmake | 2 |
4 files changed, 56 insertions, 20 deletions
diff --git a/cmake/Findjson-c.cmake b/cmake/Findjson-c.cmake index 99e2586..80a82dc 100644 --- a/cmake/Findjson-c.cmake +++ b/cmake/Findjson-c.cmake @@ -2,29 +2,25 @@ # Tries to find json-c through the config # before trying to query for it # -# if (json-c_FOUND) return() endif() -find_package(json-c CONFIG) +#find_package(json-c CONFIG) -if (JSONC_FOUND) +if (json-c_FOUND) return() endif() -find_package(PkgConfig QUIET) -if (PKG_CONFIG_FOUND) - pkg_check_modules(_JSONC json-c) - - if (BUILD_STATIC AND NOT _JSONC_FOUND) - message(FATAL_ERROR "Cannot find static build information") +if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC") + find_package(PkgConfig QUIET) + if (PKG_CONFIG_FOUND) + pkg_check_modules(_JSONC json-c) endif() - set(json-c_FOUND 1) endif() -if (json-c_FOUND) # we can rely on pkg-config +if (_JSONC_FOUND) # we can rely on pkg-config set(json-c_LINK_LIBRARIES ${_JSONC_LINK_LIBRARIES}) if (NOT BUILD_STATIC) set(json-c_INCLUDE_DIRS ${_JSONC_INCLUDE_DIRS}) @@ -33,6 +29,7 @@ if (json-c_FOUND) # we can rely on pkg-config set(json-c_INCLUDE_DIRS ${_JSONC_STATIC_INCLUDE_DIRS}) set(json-c_CFLAGS ${_JSONC_STATIC_CFLAGS_OTHER}) endif() + set(json-c_FOUND 1) else() if(CMAKE_SIZEOF_VOID_P EQUAL 8) set(_lib_suffix 64) @@ -46,8 +43,7 @@ else() ENV jsoncPath${_lib_suffix} ENV jsoncPath ${_JSONC_INCLUDE_DIRS} - PATHS - /usr/include/json-c /usr/local/include/json-c) + ) find_library(JSONC_LIB NAMES ${_JSONC_LIBRARIES} jsonc json-c @@ -56,12 +52,10 @@ else() ENV jsoncPath ${_JSONC_LIBRARY_DIRS} ${_JSONC_STATIC_LIBRARY_DIRS} - PATHS - /usr/lib{_lib_suffix} /usr/local/lib{_lib_suffix} - /usr/lib /usr/local/lib) + ) include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(json-c DEFAULT_MSG JSONC_LIB JSONC_INC) + #find_package_handle_standard_args(json-c DEFAULT_MSG JSONC_LIB JSONC_INC) mark_as_advanced(JSONC_INC JSONC_LIB) if(json-c_FOUND) @@ -73,11 +67,33 @@ else() endif() endif() + if (json-c_FOUND) + # Reconstruct the official interface add_library(json-c::json-c UNKNOWN IMPORTED) set_target_properties(json-c::json-c PROPERTIES IMPORTED_LOCATION "${json-c_LINK_LIBRARIES}" ) target_compile_definitions(json-c::json-c INTERFACE ${json-c_CFLAGS}) target_include_directories(json-c::json-c INTERFACE ${json-c_INCLUDE_DIRS}) +else() + include(FetchContent) + cmake_policy(SET CMP0077 NEW) + + message(STATUS "Downloading json-c...") + FetchContent_Declare( + jsonc + GIT_REPOSITORY https://github.com/json-c/json-c + GIT_TAG json-c-0.17 + GIT_SHALLOW TRUE + ) + + set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "") + set(BUILD_STATIC_LIBS ON CACHE INTERNAL "") + FetchContent_MakeAvailable(jsonc) + + # Only the config file includes the namespace + add_library(json-c::json-c ALIAS json-c) + + set(json-c_FOUND 1) endif() diff --git a/cmake/Findspdlog.cmake b/cmake/Findspdlog.cmake new file mode 100644 index 0000000..e54e374 --- /dev/null +++ b/cmake/Findspdlog.cmake @@ -0,0 +1,19 @@ +### Get same spdlog as Northstar + +if (spdlog_FOUND) + return() +endif() + +find_package(NorthstarPluginABI REQUIRED) +find_package(Threads REQUIRED) + +check_init_submodule(${NS_LAUNCHER_DIR}/thirdparty/spdlog) + +add_library(spdlog_header_only INTERFACE) +add_library(spdlog::spdlog_header_only ALIAS spdlog_header_only) +target_include_directories(spdlog_header_only INTERFACE "${NS_LAUNCHER_DIR}/thirdparty") +target_include_directories(spdlog_header_only INTERFACE "${NS_LAUNCHER_DIR}/thirdparty/spdlog") +target_link_libraries(spdlog_header_only INTERFACE Threads::Threads) + +set(spdlog_FOUND 1) + diff --git a/cmake/R2plugin.cmake b/cmake/R2plugin.cmake index 584ef05..cb0496e 100644 --- a/cmake/R2plugin.cmake +++ b/cmake/R2plugin.cmake @@ -9,11 +9,12 @@ cmake_policy(SET CMP0057 NEW) project(R2plugin) - if (NOT WIN32) message(FATAL_ERROR "Northstar Plugins can only be compiled for Windows") -elseif (NOT "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86_64") +elseif ("${CMAKE_SYSTEM_PROCESSOR}" AND NOT "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86_64") message(FATAL_ERROR "Northstar Plugins can only be build for x86_64") +elseif (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC") + message(WARNING "Titanfall and Northstar are built using MSVC, other compilers may not work.") endif () if (__R2PLUGIN_CMAKE_INCLUDED) diff --git a/cmake/utils.cmake b/cmake/utils.cmake index a0e0ee9..924b1ac 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -1,7 +1,7 @@ # Check if a dependency exist before trying to init git submodules function(check_init_submodule path) - file(GLOB DIR_CONTENT path) + file(GLOB DIR_CONTENT "${path}/*") list(LENGTH DIR_CONTENT CONTENT_COUNT) if (CONTENT_COUNT EQUAL 0) if (NOT EXISTS "${PROJECT_SOURCE_DIR}/.git") |