2023-10-16 00:09:31 +00:00
|
|
|
cmake_minimum_required(VERSION 3.22)
|
2023-10-15 01:38:01 +00:00
|
|
|
project(scsl LANGUAGES CXX
|
2023-10-16 22:03:22 +00:00
|
|
|
VERSION 0.2.4
|
2023-10-15 01:38:01 +00:00
|
|
|
DESCRIPTION "Shimmering Clarity Standard Library")
|
2023-10-06 03:13:46 +00:00
|
|
|
|
|
|
|
set(CMAKE_CXX_STANDARD 14)
|
2023-10-10 11:22:04 +00:00
|
|
|
set(CMAKE_VERBOSE_MAKEFILES TRUE)
|
|
|
|
set(VERBOSE YES)
|
2023-10-10 00:20:18 +00:00
|
|
|
|
2023-10-16 09:18:09 +00:00
|
|
|
# compile options:
|
|
|
|
# -Wall Default to all errors.
|
|
|
|
# -Wextra And a few extra.
|
|
|
|
# -Werror And require them to be fixed to build.
|
|
|
|
# -Wno-unused-function This is a library. Not every function is used here.
|
|
|
|
# -Wno-unused-parameter Some functions have parameters defined for compatibility,
|
|
|
|
# and aren't used in the implementation.
|
|
|
|
add_compile_options(
|
|
|
|
"-static"
|
|
|
|
"-Wall"
|
|
|
|
"-Wextra"
|
|
|
|
"-Werror"
|
|
|
|
"-Wno-unused-function"
|
|
|
|
"-Wno-unused-parameter"
|
|
|
|
"-g"
|
|
|
|
"$<$<CONFIG:RELEASE>:-O2>"
|
|
|
|
)
|
|
|
|
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
|
|
|
add_compile_options("-stdlib=libc++")
|
2023-10-10 09:35:43 +00:00
|
|
|
else ()
|
2023-10-16 09:18:09 +00:00
|
|
|
# nothing special for gcc at the moment
|
2023-10-10 09:35:43 +00:00
|
|
|
endif ()
|
2023-10-16 09:18:09 +00:00
|
|
|
|
2023-10-15 01:38:01 +00:00
|
|
|
add_compile_definitions(SCSL_DESKTOP_BUILD)
|
|
|
|
add_compile_definitions(SCSL_VERSION=${PROJECT_VERSION})
|
2023-10-06 03:13:46 +00:00
|
|
|
|
2023-10-15 01:38:01 +00:00
|
|
|
set(HEADER_FILES scsl.h
|
2023-10-10 09:35:43 +00:00
|
|
|
Arena.h
|
|
|
|
Buffer.h
|
2023-10-16 09:18:09 +00:00
|
|
|
Commander.h
|
2023-10-10 09:35:43 +00:00
|
|
|
Dictionary.h
|
2023-10-10 13:02:21 +00:00
|
|
|
Exceptions.h
|
2023-10-16 00:09:31 +00:00
|
|
|
Flag.h
|
2023-10-15 00:56:26 +00:00
|
|
|
StringUtil.h
|
2023-10-10 23:44:29 +00:00
|
|
|
TLV.h
|
2023-10-15 00:56:26 +00:00
|
|
|
Test.h
|
2023-10-16 09:18:09 +00:00
|
|
|
)
|
2023-10-09 23:37:02 +00:00
|
|
|
|
2023-10-10 02:59:21 +00:00
|
|
|
set(SOURCE_FILES
|
2023-10-10 09:35:43 +00:00
|
|
|
Arena.cc
|
|
|
|
Buffer.cc
|
2023-10-15 00:56:26 +00:00
|
|
|
Commander.cc
|
2023-10-10 09:35:43 +00:00
|
|
|
Dictionary.cc
|
2023-10-11 01:57:43 +00:00
|
|
|
Exceptions.cc
|
2023-10-16 00:09:31 +00:00
|
|
|
Flag.cc
|
2023-10-15 00:56:26 +00:00
|
|
|
StringUtil.cc
|
2023-10-10 21:01:09 +00:00
|
|
|
TLV.cc
|
2023-10-15 00:56:26 +00:00
|
|
|
Test.cc
|
2023-10-16 09:18:09 +00:00
|
|
|
)
|
2023-10-10 02:59:21 +00:00
|
|
|
|
2023-10-11 02:09:25 +00:00
|
|
|
if (APPLE)
|
2023-10-15 01:38:01 +00:00
|
|
|
add_library(scsl
|
2023-10-11 02:09:25 +00:00
|
|
|
STATIC
|
|
|
|
${SOURCE_FILES} ${HEADER_FILES})
|
|
|
|
else ()
|
2023-10-15 01:38:01 +00:00
|
|
|
add_library(scsl
|
2023-10-11 02:09:25 +00:00
|
|
|
STATIC
|
|
|
|
${SOURCE_FILES} ${HEADER_FILES})
|
|
|
|
endif()
|
2023-10-10 21:01:09 +00:00
|
|
|
|
2023-10-11 00:24:29 +00:00
|
|
|
add_executable(phonebook phonebook.cc)
|
2023-10-15 01:38:01 +00:00
|
|
|
target_link_libraries(phonebook scsl)
|
2023-10-06 03:13:46 +00:00
|
|
|
|
2023-10-10 00:20:18 +00:00
|
|
|
include(CTest)
|
|
|
|
enable_testing()
|
|
|
|
|
2023-10-16 00:09:31 +00:00
|
|
|
add_executable(buffer_test bufferTest.cc)
|
|
|
|
target_link_libraries(buffer_test scsl)
|
|
|
|
add_test(bufferTest buffer_test)
|
|
|
|
|
2023-10-06 06:17:09 +00:00
|
|
|
add_executable(tlv_test tlvTest.cc)
|
2023-10-15 01:38:01 +00:00
|
|
|
target_link_libraries(tlv_test scsl)
|
2023-10-10 00:20:18 +00:00
|
|
|
add_test(tlvTest tlv_test)
|
2023-10-06 06:08:35 +00:00
|
|
|
|
2023-10-06 06:17:09 +00:00
|
|
|
add_executable(dictionary_test dictionaryTest.cc)
|
2023-10-15 01:38:01 +00:00
|
|
|
target_link_libraries(dictionary_test scsl)
|
2023-10-10 00:20:18 +00:00
|
|
|
add_test(dictionaryTest dictionary_test)
|
2023-10-06 06:08:35 +00:00
|
|
|
|
2023-10-16 00:09:31 +00:00
|
|
|
add_executable(flag_test flagTest.cc)
|
|
|
|
target_link_libraries(flag_test scsl)
|
|
|
|
add_test(flagTest flag_test)
|
2023-10-10 00:20:18 +00:00
|
|
|
|
2023-10-15 00:56:26 +00:00
|
|
|
add_executable(stringutil_test stringutil_test.cc)
|
2023-10-15 01:38:01 +00:00
|
|
|
target_link_libraries(stringutil_test scsl)
|
2023-10-15 00:56:26 +00:00
|
|
|
add_test(stringutilTest stringutil_test)
|
|
|
|
|
2023-10-10 00:20:18 +00:00
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
write_basic_package_version_file(
|
2023-10-15 01:38:01 +00:00
|
|
|
scslConfig.cmake
|
2023-10-10 09:35:43 +00:00
|
|
|
VERSION ${PACKAGE_VERSION}
|
|
|
|
COMPATIBILITY AnyNewerVersion
|
2023-10-10 02:59:21 +00:00
|
|
|
)
|
|
|
|
|
2023-10-15 01:38:01 +00:00
|
|
|
if (NOT ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
|
2023-10-10 09:35:43 +00:00
|
|
|
add_custom_target(cloc
|
|
|
|
COMMAND cloc ${SOURCE_FILES} ${HEADER_FILES}
|
|
|
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
|
2023-10-15 01:38:01 +00:00
|
|
|
add_custom_target(deploy-docs
|
2023-10-16 00:09:31 +00:00
|
|
|
COMMAND rsync --delete-after --progress -auvz ${CMAKE_CURRENT_BINARY_DIR}/html/* docs.shimmering-clarity.net:sites/cc/${PROJECT_NAME}/
|
2023-10-15 01:38:01 +00:00
|
|
|
DEPENDS scsl_docs
|
|
|
|
)
|
2023-10-10 09:35:43 +00:00
|
|
|
|
2023-10-15 01:38:01 +00:00
|
|
|
configure_file(scsl.pc.in scsl.pc @ONLY)
|
|
|
|
install(TARGETS scsl LIBRARY DESTINATION lib)
|
2023-10-10 21:01:09 +00:00
|
|
|
install(TARGETS phonebook RUNTIME DESTINATION bin)
|
2023-10-15 01:38:01 +00:00
|
|
|
install(FILES ${HEADER_FILES} DESTINATION include/scsl)
|
|
|
|
install(FILES scslConfig.cmake DESTINATION share/scsl/cmake)
|
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/scsl.pc DESTINATION lib/pkgconfig)
|
2023-10-10 09:35:43 +00:00
|
|
|
|
2023-10-16 09:18:09 +00:00
|
|
|
include(cmake/packaging.cmake)
|
|
|
|
include(cmake/docs.cmake)
|
2023-10-11 05:17:22 +00:00
|
|
|
endif()
|