mirror of
https://github.com/vimpunk/mio.git
synced 2025-12-06 16:57:01 +08:00
79 lines
2.8 KiB
CMake
79 lines
2.8 KiB
CMake
cmake_minimum_required(VERSION 3.26)
|
|
project(mio LANGUAGES CXX)
|
|
|
|
# Set C++20 as the minimum required standard
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
# Enable CTest support if BUILD_TESTING is enabled
|
|
include(CTest)
|
|
if(BUILD_TESTING)
|
|
enable_testing()
|
|
endif()
|
|
|
|
# Create an interface library "mio" to provide the include directory.
|
|
# It is assumed that the headers are located in "single_include/mio".
|
|
add_library(mio INTERFACE)
|
|
target_include_directories(mio INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/single_include)
|
|
|
|
# Add a basic test executable that is built on all platforms.
|
|
# Note that the test source file is assumed to be located at "test/test.cpp".
|
|
add_executable(mio.test ${CMAKE_CURRENT_SOURCE_DIR}/test/test.cpp)
|
|
target_link_libraries(mio.test PRIVATE mio)
|
|
if(BUILD_TESTING)
|
|
add_test(NAME mio.test COMMAND mio.test)
|
|
endif()
|
|
|
|
# Windows-specific targets (only built on Windows)
|
|
if(WIN32)
|
|
# Unicode version: add the UNICODE compile definition.
|
|
add_executable(mio.unicode.test ${CMAKE_CURRENT_SOURCE_DIR}/test/test.cpp)
|
|
target_link_libraries(mio.unicode.test PRIVATE mio)
|
|
target_compile_definitions(mio.unicode.test PRIVATE UNICODE)
|
|
if(BUILD_TESTING)
|
|
add_test(NAME mio.unicode.test COMMAND mio.unicode.test)
|
|
endif()
|
|
|
|
# Full WinAPI version (adjust additional settings as needed).
|
|
add_executable(mio.fullwinapi.test ${CMAKE_CURRENT_SOURCE_DIR}/test/test.cpp)
|
|
target_link_libraries(mio.fullwinapi.test PRIVATE mio)
|
|
if(BUILD_TESTING)
|
|
add_test(NAME mio.fullwinapi.test COMMAND mio.fullwinapi.test)
|
|
endif()
|
|
|
|
# Minimal WinAPI version: minimal Windows API configuration.
|
|
add_executable(mio.minwinapi.test ${CMAKE_CURRENT_SOURCE_DIR}/test/test.cpp)
|
|
target_link_libraries(mio.minwinapi.test PRIVATE mio)
|
|
if(BUILD_TESTING)
|
|
add_test(NAME mio.minwinapi.test COMMAND mio.minwinapi.test)
|
|
endif()
|
|
endif()
|
|
|
|
#
|
|
# Rudimentary CPack support.
|
|
#
|
|
# CPack provides a mechanism to generate installation packaging for a project,
|
|
# e.g., self-extracting shell scripts, compressed tarballs, Debian Package files,
|
|
# RPM Package Manager files, Windows NSIS installation wizards,
|
|
# Apple Disk Images (.dmg), etc.
|
|
#
|
|
# A packaged installation can be generated by calling
|
|
#
|
|
# ```sh
|
|
# cpack -G <packaging type> --config CPackConfig.cmake
|
|
# ```
|
|
#
|
|
# See `cpack --help` or the CPack documentation for more information.
|
|
#
|
|
if(NOT subproject)
|
|
set(CPACK_PACKAGE_VENDOR "mandreyel")
|
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
|
|
"Cross-platform C++20 header-only library for memory mapped file IO")
|
|
set(CMAKE_PROJECT_HOMEPAGE_URL "https://github.com/Twilight-Dream-Of-Magic/mio")
|
|
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
|
|
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
|
|
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
|
|
set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
|
|
include(CPack)
|
|
endif()
|