Files
mars-nwe/third_party/CMakeLists.txt
Mario Fetka 0f82de2743
All checks were successful
Source release / source-package (push) Successful in 1m20s
0536 build: introduce libnwnss for imported NSS runtime
2026-06-14 22:34:04 +02:00

149 lines
6.8 KiB
CMake

# Third-party dependency owner for mars-nwe.
#
# The root CMake file enters this directory once. This file owns all bundled
# dependency checks, target setup and local build policy so root/src/tests do not
# need to know individual third_party subdirectory details.
set(MARS_NWE_THIRD_PARTY_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}" CACHE INTERNAL "mars-nwe third-party source directory")
set(MARS_NWE_YYJSON_SOURCE_DIR
"${MARS_NWE_THIRD_PARTY_SOURCE_DIR}/yyjson"
CACHE PATH "Path to the bundled yyjson source tree")
set(MARS_NWE_UNICODE_TABLES_SOURCE_DIR
"${MARS_NWE_THIRD_PARTY_SOURCE_DIR}/unicodeTables"
CACHE PATH "Path to bundled mars-unicode-tables source tree")
set(MARS_NWE_INIPARSER_SOURCE_DIR
"${MARS_NWE_THIRD_PARTY_SOURCE_DIR}/iniparser"
CACHE PATH "Path to bundled iniParser source tree")
set(MARS_NWE_TERMBOX2_SOURCE_DIR
"${MARS_NWE_THIRD_PARTY_SOURCE_DIR}/termbox2"
CACHE PATH "Path to bundled termbox2 source tree")
if(NOT EXISTS "${MARS_NWE_YYJSON_SOURCE_DIR}/src/yyjson.c" OR
NOT EXISTS "${MARS_NWE_YYJSON_SOURCE_DIR}/src/yyjson.h")
message(FATAL_ERROR
"Bundled yyjson source is required. Run: git submodule update --init --recursive third_party/yyjson")
endif()
if(NOT EXISTS "${MARS_NWE_UNICODE_TABLES_SOURCE_DIR}/TAB/unicodeTables.c" OR
NOT EXISTS "${MARS_NWE_UNICODE_TABLES_SOURCE_DIR}/TAB/codepageTables.c" OR
NOT EXISTS "${MARS_NWE_UNICODE_TABLES_SOURCE_DIR}/TAB/codepageTables.h")
message(FATAL_ERROR
"Bundled Unicode/codepage tables are required. Run: git submodule update --init --recursive third_party/unicodeTables")
endif()
if(NOT EXISTS "${MARS_NWE_INIPARSER_SOURCE_DIR}/src/iniparser.c" OR
NOT EXISTS "${MARS_NWE_INIPARSER_SOURCE_DIR}/src/iniparser.h" OR
NOT EXISTS "${MARS_NWE_INIPARSER_SOURCE_DIR}/src/dictionary.c" OR
NOT EXISTS "${MARS_NWE_INIPARSER_SOURCE_DIR}/src/dictionary.h")
message(FATAL_ERROR
"Bundled iniParser is required. Run: git submodule update --init third_party/iniparser")
endif()
if(NOT EXISTS "${MARS_NWE_TERMBOX2_SOURCE_DIR}/termbox2.h")
message(FATAL_ERROR
"Bundled termbox2 is required for nwtui. Run: git submodule update --init third_party/termbox2")
endif()
add_library(mars_nwe_yyjson STATIC
"${MARS_NWE_YYJSON_SOURCE_DIR}/src/yyjson.c")
add_library(mars_nwe::yyjson ALIAS mars_nwe_yyjson)
set_target_properties(mars_nwe_yyjson PROPERTIES
POSITION_INDEPENDENT_CODE ON)
target_compile_features(mars_nwe_yyjson PRIVATE c_std_99)
target_compile_definitions(mars_nwe_yyjson PRIVATE
YYJSON_DISABLE_INCR_READER
YYJSON_DISABLE_UTILS
YYJSON_DISABLE_FAST_FP_CONV
YYJSON_DISABLE_NON_STANDARD)
target_include_directories(mars_nwe_yyjson PUBLIC
"${MARS_NWE_YYJSON_SOURCE_DIR}/src")
add_library(mars_nwe_iniparser STATIC
"${MARS_NWE_INIPARSER_SOURCE_DIR}/src/iniparser.c"
"${MARS_NWE_INIPARSER_SOURCE_DIR}/src/dictionary.c")
add_library(mars_nwe::iniparser ALIAS mars_nwe_iniparser)
set_target_properties(mars_nwe_iniparser PROPERTIES
POSITION_INDEPENDENT_CODE ON)
target_compile_features(mars_nwe_iniparser PRIVATE c_std_99)
target_include_directories(mars_nwe_iniparser PUBLIC
"${MARS_NWE_INIPARSER_SOURCE_DIR}/src")
add_library(mars_nwe_unicode_tables STATIC
"${MARS_NWE_UNICODE_TABLES_SOURCE_DIR}/TAB/unicodeTables.c"
"${MARS_NWE_UNICODE_TABLES_SOURCE_DIR}/TAB/codepageTables.c")
add_library(mars_nwe::unicode_tables ALIAS mars_nwe_unicode_tables)
set_target_properties(mars_nwe_unicode_tables PROPERTIES
POSITION_INDEPENDENT_CODE ON)
target_compile_features(mars_nwe_unicode_tables PRIVATE c_std_99)
target_include_directories(mars_nwe_unicode_tables
PUBLIC
"${MARS_NWE_UNICODE_TABLES_SOURCE_DIR}/TAB"
PRIVATE
"${CMAKE_SOURCE_DIR}/include/nwnss"
"${CMAKE_SOURCE_DIR}/include/nwnss/include"
"${CMAKE_SOURCE_DIR}/include/nwnss/library"
"${CMAKE_SOURCE_DIR}/include/nwnss/public")
add_library(mars_nwe_termbox2 INTERFACE)
add_library(mars_nwe::termbox2 ALIAS mars_nwe_termbox2)
target_include_directories(mars_nwe_termbox2 INTERFACE
"${MARS_NWE_TERMBOX2_SOURCE_DIR}")
message(STATUS "Salvage JSON backend: yyjson built through third_party")
message(STATUS "Core INI backend: iniParser built through third_party")
message(STATUS "NSS Unicode/codepage tables: mars-unicode-tables built through third_party")
message(STATUS "TUI terminal backend: termbox2 interface target")
# mars-nwe private third-party stack. These are built with the nw namespace so
# they can be installed next to system libraries and headers without collisions.
set(LIBOWFAT_LIBRARY_PREFIX nw CACHE STRING "" FORCE)
set(LIBOWFAT_BUILD_SHARED ON CACHE BOOL "" FORCE)
set(LIBOWFAT_BUILD_STATIC OFF CACHE BOOL "" FORCE)
set(LIBOWFAT_BUILD_TEST_PROGRAMS OFF CACHE BOOL "" FORCE)
set(LIBOWFAT_RUN_SELF_TESTS OFF CACHE BOOL "" FORCE)
set(SODIUM_LIBRARY_PREFIX nw CACHE STRING "" FORCE)
set(SODIUM_DISABLE_TESTS ON CACHE BOOL "" FORCE)
set(SODIUM_INSTALL ON CACHE BOOL "" FORCE)
set(MATRIXSSL_LIBRARY_PREFIX nw CACHE STRING "" FORCE)
set(MATRIXSSL_BUILD_SHARED ON CACHE BOOL "" FORCE)
set(MATRIXSSL_BUILD_STATIC OFF CACHE BOOL "" FORCE)
set(MATRIXSSL_BUILD_OPENSSL_COMPAT OFF CACHE BOOL "" FORCE)
set(MATRIXSSL_USE_SODIUM ON CACHE BOOL "" FORCE)
set(MATRIXSSL_BUILD_TESTS ${MARS_NWE_BUILD_MATRIXSSL_PROGRAMS} CACHE BOOL "" FORCE)
set(MATRIXSSL_BUILD_APPS ${MARS_NWE_BUILD_MATRIXSSL_PROGRAMS} CACHE BOOL "" FORCE)
set(MATRIXSSL_BUILD_TOOLS ${MARS_NWE_BUILD_MATRIXSSL_PROGRAMS} CACHE BOOL "" FORCE)
foreach(_mars_nwe_third_party IN ITEMS
libowfat
libsodium
matrixssl)
if(NOT EXISTS "${MARS_NWE_THIRD_PARTY_SOURCE_DIR}/${_mars_nwe_third_party}/CMakeLists.txt")
message(FATAL_ERROR "Missing third_party/${_mars_nwe_third_party}; run git submodule update --init --recursive")
endif()
endforeach()
add_subdirectory(libowfat)
set(_MARS_NWE_SAVED_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS ON)
add_subdirectory(libsodium)
set(BUILD_SHARED_LIBS ${_MARS_NWE_SAVED_BUILD_SHARED_LIBS})
add_subdirectory(matrixssl)
function(mars_nwe_add_flaim_third_party)
# Optional directory/FLAIM stack depends on nwssl from src/ssl, so the root
# calls this function after add_subdirectory(src). Keep the actual flaim
# subdirectory policy here, next to the other bundled dependencies.
set(NWFLAIM_LIBRARY_PREFIX nw CACHE STRING "" FORCE)
set(NWFLAIM_BUILD_SHARED ON CACHE BOOL "" FORCE)
set(NWFLAIM_BUILD_STATIC OFF CACHE BOOL "" FORCE)
set(NWFLAIM_BUILD_SQL OFF CACHE BOOL "" FORCE)
set(NWFLAIM_WITH_OPENSSL ON CACHE BOOL "" FORCE)
set(NWFLAIM_USE_NICI ON CACHE BOOL "" FORCE)
set(NWFLAIM_SSL_TARGET mars_nwe::ssl CACHE STRING "" FORCE)
set(NWFLAIM_NICI_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/include/nwssl/private/nici" CACHE PATH "" FORCE)
add_subdirectory("${MARS_NWE_THIRD_PARTY_SOURCE_DIR}/flaim" "${CMAKE_BINARY_DIR}/third_party/flaim")
endfunction()