-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds modern CMake support, allowing SheenBidi to be used as a subproject from a CMake project (e.g. via `FetchContent`).
- Loading branch information
Showing
2 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
|
||
project(sheenbidi VERSION 2.8 LANGUAGES C CXX) | ||
|
||
option(ENABLE_INSTALL "Enable install targets" ON) | ||
|
||
set(CMAKE_CXX_STANDARD 20) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
set(CMAKE_CXX_STANDARD_REQUIRED OFF) | ||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # for clang-tidy | ||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON) | ||
|
||
set(_public_headers | ||
Headers/SBAlgorithm.h | ||
Headers/SBBase.h | ||
Headers/SBBidiType.h | ||
Headers/SBCodepoint.h | ||
Headers/SBCodepointSequence.h | ||
Headers/SBGeneralCategory.h | ||
Headers/SBLine.h | ||
Headers/SBMirrorLocator.h | ||
Headers/SBParagraph.h | ||
Headers/SBRun.h | ||
Headers/SBScript.h | ||
Headers/SBScriptLocator.h | ||
Headers/SheenBidi.h | ||
) | ||
add_library( | ||
sheenbidi | ||
Source/SheenBidi.c | ||
) | ||
target_include_directories(sheenbidi PUBLIC | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Headers> | ||
$<INSTALL_INTERFACE:include/SheenBidi> | ||
) | ||
target_include_directories(sheenbidi PRIVATE Source) | ||
set_target_properties(sheenbidi PROPERTIES PUBLIC_HEADER "${_public_headers}") | ||
target_compile_definitions(sheenbidi PRIVATE SB_CONFIG_UNITY) | ||
add_library(SheenBidi::sheenbidi ALIAS sheenbidi) | ||
|
||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") | ||
target_link_libraries(sheenbidi PUBLIC "-static-libgcc -static-libstdc++") | ||
endif() | ||
|
||
if(ENABLE_INSTALL) | ||
install( | ||
TARGETS sheenbidi | ||
EXPORT SheenBidiTargets | ||
PUBLIC_HEADER | ||
CONFIGURATIONS Release | ||
DESTINATION include/SheenBidi | ||
) | ||
|
||
if(NOT DEFINED LIB_INSTALL_DIR) | ||
set(LIB_INSTALL_DIR lib) | ||
endif() | ||
set(ConfigPackageLocation "${LIB_INSTALL_DIR}/cmake/SheenBidi") | ||
|
||
include(CMakePackageConfigHelpers) | ||
configure_package_config_file(cmake/SheenBidi.cmake.in | ||
"${CMAKE_CURRENT_BINARY_DIR}/SheenBidi/SheenBidiConfig.cmake" | ||
INSTALL_DESTINATION ${ConfigPackageLocation}) | ||
write_basic_package_version_file( | ||
"${CMAKE_CURRENT_BINARY_DIR}/SheenBidi/SheenBidiConfigVersion.cmake" | ||
VERSION ${SheenBidi_VERSION} | ||
COMPATIBILITY AnyNewerVersion | ||
) | ||
|
||
export(EXPORT SheenBidiTargets | ||
FILE "${CMAKE_CURRENT_BINARY_DIR}/SheenBidi/SheenBidiTargets.cmake" | ||
NAMESPACE SheenBidi:: | ||
) | ||
|
||
install(EXPORT SheenBidiTargets | ||
FILE | ||
SheenBidiTargets.cmake | ||
NAMESPACE | ||
SheenBidi:: | ||
DESTINATION | ||
${ConfigPackageLocation} | ||
) | ||
install( | ||
FILES | ||
"${CMAKE_CURRENT_BINARY_DIR}/SheenBidi/SheenBidiConfig.cmake" | ||
"${CMAKE_CURRENT_BINARY_DIR}/SheenBidi/SheenBidiConfigVersion.cmake" | ||
DESTINATION | ||
${ConfigPackageLocation} | ||
) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@PACKAGE_INIT@ | ||
|
||
check_required_components(SheenBidi) | ||
|
||
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]") |