scsl/CMakeLists.txt

99 lines
2.7 KiB
CMake
Raw Normal View History

2023-10-06 03:13:46 +00:00
cmake_minimum_required(VERSION 3.25)
project(klib LANGUAGES CXX
VERSION 0.0.1
DESCRIPTION "Kyle's C++ 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
if (MSVC)
add_compile_options("/W4" "$<$<CONFIG:RELEASE>:/O2>")
else ()
2023-10-11 01:57:43 +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("-Wall" "-Wextra" "-Werror" "-Wno-unused-function" "-Wno-unused-parameter" "$<$<CONFIG:RELEASE>:-O2>")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options("-stdlib=libc++")
else ()
# nothing special for gcc at the moment
endif ()
endif ()
2023-10-06 06:08:35 +00:00
add_compile_options("-DDESKTOP_BUILD")
2023-10-06 03:13:46 +00:00
2023-10-09 23:37:02 +00:00
set(HEADER_FILES
klib.h
Arena.h
Buffer.h
Dictionary.h
2023-10-10 13:02:21 +00:00
Exceptions.h
Test.h
2023-10-10 23:44:29 +00:00
TLV.h
WinHelpers.h)
2023-10-09 23:37:02 +00:00
2023-10-10 02:59:21 +00:00
set(SOURCE_FILES
Arena.cc
Buffer.cc
Dictionary.cc
2023-10-11 01:57:43 +00:00
Exceptions.cc
Test.cc
TLV.cc
2023-10-11 01:57:43 +00:00
Commander.cc
2023-10-10 23:44:29 +00:00
Commander.h
2023-10-11 00:24:29 +00:00
WinHelpers.cc)
2023-10-10 02:59:21 +00:00
2023-10-11 02:09:25 +00:00
if (APPLE)
add_library(klib
STATIC
${SOURCE_FILES} ${HEADER_FILES})
else ()
add_library(klib
STATIC
${SOURCE_FILES} ${HEADER_FILES})
endif()
2023-10-11 00:24:29 +00:00
add_executable(phonebook phonebook.cc)
2023-10-10 13:02:21 +00:00
target_link_libraries(phonebook klib)
2023-10-06 03:13:46 +00:00
2023-10-10 00:20:18 +00:00
include(CTest)
enable_testing()
2023-10-06 06:17:09 +00:00
add_executable(tlv_test tlvTest.cc)
2023-10-06 03:13:46 +00:00
target_link_libraries(tlv_test klib)
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)
target_link_libraries(dictionary_test klib)
2023-10-10 00:20:18 +00:00
add_test(dictionaryTest dictionary_test)
2023-10-06 06:08:35 +00:00
2023-10-09 17:24:40 +00:00
add_executable(buffer_test bufferTest.cc)
target_link_libraries(buffer_test klib)
2023-10-10 00:20:18 +00:00
add_test(bufferTest buffer_test)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
klibConfig.cmake
VERSION ${PACKAGE_VERSION}
COMPATIBILITY AnyNewerVersion
2023-10-10 02:59:21 +00:00
)
add_custom_target(cloc
COMMAND cloc ${SOURCE_FILES} ${HEADER_FILES}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
configure_file(klib.pc.in klib.pc @ONLY)
install(TARGETS klib LIBRARY DESTINATION lib)
install(TARGETS phonebook RUNTIME DESTINATION bin)
install(FILES ${HEADER_FILES} DESTINATION include/klib)
install(FILES klibConfig.cmake DESTINATION share/klib/cmake)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/klib.pc DESTINATION lib/pkgconfig)
2023-10-10 02:59:21 +00:00
include(CMakePack.txt)
include(CMakeDocs.txt)