|
| 1 | +cmake_minimum_required(VERSION 3.28) |
| 2 | + |
| 3 | +project(lwg) |
| 4 | + |
| 5 | +### Configuration |
| 6 | + |
| 7 | +set(mailing_directory ${CMAKE_CURRENT_SOURCE_DIR}/mailing) |
| 8 | + |
| 9 | +# Tell MSVC to behave |
| 10 | +add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8;/Zc:__cplusplus;\ |
| 11 | +$<$<VERSION_LESS:$<TARGET_PROPERTY:CXX_STANDARD>,20>:/permissive->>") |
| 12 | + |
| 13 | +# Enable ASan (and UBSan with non-MSVC) for Debug builds |
| 14 | +set(sanitizer_options "$<$<CONFIG:Debug>:\ |
| 15 | +-fsanitize=address$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:$<COMMA>undefined>>") |
| 16 | +add_compile_options(${sanitizer_options}) |
| 17 | +add_link_options(${sanitizer_options}) |
| 18 | + |
| 19 | +# Enable Standard Library assertions |
| 20 | +include(CheckCXXSymbolExists) |
| 21 | + |
| 22 | +if(cxx_std_20 IN_LIST CMAKE_CXX_COMPILE_FEATURES) |
| 23 | + set(cxx_detect_header version) |
| 24 | +else() |
| 25 | + set(cxx_detect_header ciso646) |
| 26 | +endif() |
| 27 | + |
| 28 | +check_cxx_symbol_exists(__GLIBCXX__ ${cxx_detect_header} stl_is_libstdcxx) |
| 29 | +if(${stl_is_libstdcxx}) |
| 30 | + add_compile_definitions(_GLIBCXX_ASSERTIONS_ $<$<CONFIG:Debug>:_GLIBCXX_DEBUG>) |
| 31 | +endif() |
| 32 | + |
| 33 | +check_cxx_symbol_exists(_LIBCPP_VERSION ${cxx_detect_header} stl_is_libcxx) |
| 34 | +if(${stl_is_libcxx}) |
| 35 | + # Untested: |
| 36 | + add_compile_definitions(_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE$<IF:$<CONFIG:Debug>,_DEBUG,_FAST>) |
| 37 | +endif() |
| 38 | + |
| 39 | +check_cxx_symbol_exists(_MSVC_STL_VERSION ${cxx_detect_header} stl_is_msvcstl) |
| 40 | +if(${stl_is_msvcstl}) |
| 41 | + add_compile_definitions(_CONTAINER_DEBUG_LEVEL) |
| 42 | +endif() |
| 43 | + |
| 44 | +# LTO, because why not |
| 45 | +set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE On) |
| 46 | +set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO On) |
| 47 | + |
| 48 | +### Program targets |
| 49 | +add_library(lwg |
| 50 | + src/date.cpp src/issues.cpp src/mailing_info.cpp src/metadata.cpp |
| 51 | + src/report_generator.cpp src/sections.cpp src/status.cpp) |
| 52 | +target_sources(lwg PUBLIC FILE_SET headers TYPE HEADERS BASE_DIRS src |
| 53 | + FILES src/date.h src/html_utils.h src/issues.h src/mailing_info.h |
| 54 | + src/metadata.h src/report_generator.h src/sections.h src/status.h) |
| 55 | +target_compile_features(lwg PUBLIC cxx_std_17) |
| 56 | + |
| 57 | +add_executable(list_issues src/list_issues.cpp) |
| 58 | +target_link_libraries(list_issues lwg) |
| 59 | + |
| 60 | +add_executable(lists src/lists.cpp) |
| 61 | +target_link_libraries(lists lwg) |
| 62 | + |
| 63 | +add_executable(section_data src/section_data.cpp) |
| 64 | +target_link_libraries(section_data lwg) |
| 65 | + |
| 66 | +add_executable(set_status src/set_status.cpp) |
| 67 | +target_link_libraries(set_status lwg) |
| 68 | + |
| 69 | +add_executable(toc_diff src/toc_diff.cpp) |
| 70 | +target_link_libraries(toc_diff lwg) |
| 71 | + |
| 72 | +file(GLOB issue_files CONFIGURE_DEPENDS xml/issue*.xml) |
| 73 | +add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/meta-data/dates |
| 74 | + COMMENT "Refreshing 'Last modified' timestamps for issues..." |
| 75 | + COMMAND git whatchanged --no-show-signature --pretty=%ct | python bin/make_dates.py > meta-data/dates |
| 76 | + VERBATIM |
| 77 | + MAIN_DEPENDENCY bin/make_dates.py DEPENDS ${issue_files} |
| 78 | + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) |
| 79 | + |
| 80 | +### Utility targets |
| 81 | +add_custom_target(build_lists COMMAND lists DEPENDS lists mailing |
| 82 | + COMMENT "Generating HTML lists" |
| 83 | + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) |
| 84 | + |
| 85 | +add_custom_target(dates DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/meta-data/dates) |
| 86 | + |
| 87 | +add_custom_target(distclean DEPENDS clean COMMAND cmake -E rm -rf ${mailing_directory} VERBATIM) |
| 88 | + |
| 89 | +add_custom_target(lint COMMAND bash -c bin/lint.sh VERBATIM |
| 90 | + COMMENT "Validating XML issue files" |
| 91 | + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) |
| 92 | + |
| 93 | +add_custom_target(pgms DEPENDS lists section_data toc_diff list_issues set_status) |
| 94 | + |
| 95 | +add_custom_target(history COMMAND lists revision history VERBATIM DEPENDS lists |
| 96 | + COMMENT "Generating revision history" |
| 97 | + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) |
| 98 | + |
| 99 | +add_custom_target(mailing COMMAND ${CMAKE_COMMAND} -E make_directory ${mailing_directory} VERBATIM) |
0 commit comments