cesium-native/CMakeLists.txt

105 lines
3.1 KiB
CMake

cmake_minimum_required(VERSION 3.15)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
project(cesium-native
VERSION 0.1.0
LANGUAGES CXX
)
if (NOT DEFINED GLOB_USE_CONFIGURE_DEPENDS)
set(GLOB_USE_CONFIGURE_DEPENDS OFF CACHE BOOL
"Controls if cesium-native targets should use configure_depends or not for globbing their sources"
)
endif()
# Use configure_depends to automatically reconfigure on filesystem
# changes at the expense of computational overhead for CMake to
# determine if new files have been added (-DGLOB_USE_CONFIGURE_DEPENDS).
function(cesium_glob_files out_var_name regexes)
set(files "")
foreach(arg ${ARGV})
list(APPEND regexes_only "${arg}")
endforeach()
list(POP_FRONT regexes_only)
if (GLOB_USE_CONFIGURE_DEPENDS)
file(GLOB_RECURSE files CONFIGURE_DEPENDS ${regexes_only})
else()
file(GLOB files ${regexes_only})
endif()
set(${ARGV0} "${files}" PARENT_SCOPE)
endfunction()
# Workaround for targets that erroneously forget to
# declare their include directories as `SYSTEM`
function(target_link_libraries_system target scope)
set(libs ${ARGN})
foreach(lib ${libs})
get_target_property(lib_include_dirs ${lib} INTERFACE_INCLUDE_DIRECTORIES)
if ("${lib_include_dirs}" MATCHES ".*NOTFOUND$")
message(FATAL_ERROR "${target}: Cannot use INTERFACE_INCLUDE_DIRECTORIES from target ${lib} as it does not define it")
endif()
target_include_directories(${target} SYSTEM ${scope} ${lib_include_dirs})
target_link_libraries(${target} ${scope} ${lib})
endforeach()
endfunction()
# Shared object support is currently NOT working on Windows
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
function(configure_cesium_library targetName)
if (MSVC)
target_compile_options(${targetName} PRIVATE /W4 /WX /wd4201)
else()
target_compile_options(${targetName} PRIVATE -Werror -Wall -Wextra -Wconversion -Wpedantic -Wshadow -Wsign-conversion)
endif()
set_target_properties(${targetName} PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)
if (BUILD_SHARED_LIBS)
target_compile_definitions(
${targetName}
PUBLIC
CESIUM_SHARED=${BUILD_SHARED_LIBS}
)
endif()
if (NOT ${targetName} MATCHES "cesium-native-tests")
string(TOUPPER ${targetName} capitalizedTargetName)
target_compile_definitions(
${targetName}
PRIVATE
${capitalizedTargetName}_BUILDING
)
endif()
endfunction()
# Private Libraries
add_subdirectory(extern EXCLUDE_FROM_ALL)
# Public Targets
add_subdirectory(CesiumUtility)
add_subdirectory(CesiumGltf)
add_subdirectory(CesiumGeometry)
add_subdirectory(CesiumGeospatial)
add_subdirectory(CesiumGltfReader)
add_subdirectory(CesiumAsync)
add_subdirectory(Cesium3DTiles)
add_subdirectory(CesiumIonClient)
# Private Targets
# enable_testing() MUST be called before add_subdirectory or no tests
# will be found by ctest
enable_testing()
add_subdirectory(CesiumNativeTests)
add_subdirectory(doc)