diff --git a/CMakeLists.txt b/CMakeLists.txt index 84c86400..16d12f22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -157,11 +157,6 @@ if(WIN32 OR APPLE) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") endif() -# Build number define -if(BUILD_NUMBER) - add_compile_definitions("BUILD_NUMBER=\"${BUILD_NUMBER}\"") -endif() - # --- Subdirectories (dependency order) --- add_subdirectory(third_party) add_subdirectory(compressed_archive) diff --git a/YACReader/CMakeLists.txt b/YACReader/CMakeLists.txt index a6fcded6..ea9322df 100644 --- a/YACReader/CMakeLists.txt +++ b/YACReader/CMakeLists.txt @@ -45,6 +45,7 @@ qt_add_executable(YACReader WIN32 ${PROJECT_SOURCE_DIR}/common/themes/theme_manager.h ${PROJECT_SOURCE_DIR}/common/themes/theme_manager.cpp ) +yacreader_apply_build_options(YACReader) target_include_directories(YACReader PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/YACReaderLibrary/CMakeLists.txt b/YACReaderLibrary/CMakeLists.txt index d8586d48..38faf04c 100644 --- a/YACReaderLibrary/CMakeLists.txt +++ b/YACReaderLibrary/CMakeLists.txt @@ -31,6 +31,7 @@ target_include_directories(library_common PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/db ) +yacreader_apply_build_options(library_common) target_link_libraries(library_common PUBLIC Qt6::Core Qt6::Core5Compat @@ -62,6 +63,7 @@ target_include_directories(db_helper PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/db ) +yacreader_apply_build_options(db_helper) target_link_libraries(db_helper PUBLIC Qt6::Core Qt6::Sql @@ -179,6 +181,7 @@ qt_add_executable(YACReaderLibrary WIN32 ${PROJECT_SOURCE_DIR}/common/themes/theme_manager.h ${PROJECT_SOURCE_DIR}/common/themes/theme_manager.cpp ) +yacreader_apply_build_options(YACReaderLibrary) # macOS-specific sources if(APPLE) diff --git a/YACReaderLibrary/comic_vine/CMakeLists.txt b/YACReaderLibrary/comic_vine/CMakeLists.txt index 947d01b6..382e3f0f 100644 --- a/YACReaderLibrary/comic_vine/CMakeLists.txt +++ b/YACReaderLibrary/comic_vine/CMakeLists.txt @@ -54,6 +54,7 @@ target_include_directories(comic_vine PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/model ) +yacreader_apply_build_options(comic_vine) # App-specific theme.h needed for themable.h → theme_manager.h → theme.h chain target_include_directories(comic_vine PRIVATE ${PROJECT_SOURCE_DIR}/YACReaderLibrary/themes diff --git a/YACReaderLibrary/server/CMakeLists.txt b/YACReaderLibrary/server/CMakeLists.txt index af7b337e..839072ef 100644 --- a/YACReaderLibrary/server/CMakeLists.txt +++ b/YACReaderLibrary/server/CMakeLists.txt @@ -67,6 +67,7 @@ target_include_directories(server PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/controllers ${CMAKE_CURRENT_SOURCE_DIR}/controllers/v2 ) +yacreader_apply_build_options(server) target_compile_definitions(server PUBLIC SERVER_VERSION_NUMBER="2.1") if(UNIX AND NOT APPLE) target_compile_definitions(server PRIVATE diff --git a/YACReaderLibraryServer/CMakeLists.txt b/YACReaderLibraryServer/CMakeLists.txt index efaf364a..ed45d453 100644 --- a/YACReaderLibraryServer/CMakeLists.txt +++ b/YACReaderLibraryServer/CMakeLists.txt @@ -7,6 +7,7 @@ qt_add_executable(YACReaderLibraryServer libraries_updater.h libraries_updater.cpp ) +yacreader_apply_build_options(YACReaderLibraryServer) target_include_directories(YACReaderLibraryServer PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} @@ -18,6 +19,9 @@ target_compile_definitions(YACReaderLibraryServer PRIVATE SERVER_RELEASE YACREADER_LIBRARY ) +if(BUILD_NUMBER) + target_compile_definitions(YACReaderLibraryServer PRIVATE "BUILD_NUMBER=\"${BUILD_NUMBER}\"") +endif() # Translations qt_add_translations(YACReaderLibraryServer diff --git a/cmake/CompilerOptions.cmake b/cmake/CompilerOptions.cmake index c90fa6f8..429cf995 100644 --- a/cmake/CompilerOptions.cmake +++ b/cmake/CompilerOptions.cmake @@ -1,13 +1,31 @@ -# Compiler options for YACReader +# Compiler policy for YACReader-owned targets. +# Keep this target internal so third-party code does not inherit our rules. +add_library(yacreader_build_options INTERFACE) + +target_compile_definitions(yacreader_build_options INTERFACE + QT_DISABLE_DEPRECATED_UP_TO=0x060400 +) if(MSVC) - # Prevent windows.h from defining min/max macros that conflict with - # std::min, std::max, std::numeric_limits::max(), etc. - add_compile_definitions(NOMINMAX) + target_compile_definitions(yacreader_build_options INTERFACE + # Prevent windows.h from defining min/max macros that conflict with + # std::min, std::max, std::numeric_limits::max(), etc. + NOMINMAX + ) - # /Zc:__cplusplus: report correct __cplusplus value - # /permissive-: strict standard conformance - add_compile_options(/Zc:__cplusplus /permissive-) + target_compile_options(yacreader_build_options INTERFACE + # /Zc:__cplusplus: report correct __cplusplus value + # /permissive-: strict standard conformance + $<$:/Zc:__cplusplus> + $<$:/permissive-> + ) endif() -add_compile_definitions(QT_DISABLE_DEPRECATED_UP_TO=0x060400) +function(yacreader_apply_build_options) + foreach(target_name IN LISTS ARGN) + if(NOT TARGET "${target_name}") + message(FATAL_ERROR "yacreader_apply_build_options(): unknown target '${target_name}'") + endif() + target_link_libraries("${target_name}" PRIVATE yacreader_build_options) + endforeach() +endfunction() diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index d8017a65..ba76f7cf 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -18,6 +18,7 @@ target_include_directories(yr_global PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) +yacreader_apply_build_options(yr_global) target_link_libraries(yr_global PUBLIC Qt6::Core) if(UNIX AND NOT APPLE) target_compile_definitions(yr_global PRIVATE @@ -30,6 +31,7 @@ add_library(naturalsort STATIC qnaturalsorting.cpp ) target_include_directories(naturalsort PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +yacreader_apply_build_options(naturalsort) target_link_libraries(naturalsort PUBLIC Qt6::Core) # --- concurrent_queue --- @@ -38,6 +40,7 @@ add_library(concurrent_queue STATIC concurrent_queue.cpp ) target_include_directories(concurrent_queue PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +yacreader_apply_build_options(concurrent_queue) target_link_libraries(concurrent_queue PUBLIC Qt6::Core) # --- worker (header-only thread helpers) --- @@ -66,6 +69,7 @@ add_library(common_all STATIC global_info_provider.cpp ) target_include_directories(common_all PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +yacreader_apply_build_options(common_all) target_link_libraries(common_all PUBLIC Qt6::Core Qt6::Gui @@ -82,6 +86,7 @@ add_library(comic_backend STATIC comic.cpp pdf_comic.h ) +yacreader_apply_build_options(comic_backend) # PDF source depends on backend if(PDF_BACKEND STREQUAL "pdfkit") @@ -144,6 +149,7 @@ target_include_directories(common_gui PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/themes ${CMAKE_CURRENT_SOURCE_DIR}/themes/shared ) +yacreader_apply_build_options(common_gui) target_link_libraries(common_gui PUBLIC Qt6::Core @@ -176,6 +182,7 @@ target_include_directories(rhi_flow_reader PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/rhi ) +yacreader_apply_build_options(rhi_flow_reader) target_compile_definitions(rhi_flow_reader PRIVATE YACREADER) target_link_libraries(rhi_flow_reader PUBLIC Qt6::Core @@ -200,6 +207,7 @@ target_include_directories(rhi_flow_library PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/rhi ) +yacreader_apply_build_options(rhi_flow_library) target_compile_definitions(rhi_flow_library PRIVATE YACREADER_LIBRARY) target_link_libraries(rhi_flow_library PUBLIC Qt6::Core diff --git a/compressed_archive/CMakeLists.txt b/compressed_archive/CMakeLists.txt index a5f5ba5c..6fd5adcf 100644 --- a/compressed_archive/CMakeLists.txt +++ b/compressed_archive/CMakeLists.txt @@ -2,6 +2,7 @@ # Switched on DECOMPRESSION_BACKEND: unarr | 7zip | libarchive add_library(cbx_backend STATIC) +yacreader_apply_build_options(cbx_backend) if(DECOMPRESSION_BACKEND STREQUAL "unarr") message(STATUS "Decompression backend: unarr") @@ -88,14 +89,14 @@ elseif(DECOMPRESSION_BACKEND STREQUAL "7zip") if(APPLE) target_compile_definitions(cbx_backend PRIVATE - _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE NDEBUG _REENTRANT + _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE _REENTRANT ENV_UNIX _7ZIP_LARGE_PAGES ENV_MACOSX _TCHAR_DEFINED UNICODE _UNICODE UNIX_USE_WIN_FILE) target_link_libraries(cbx_backend PRIVATE "-framework IOKit" "-framework CoreFoundation") elseif(UNIX) target_compile_definitions(cbx_backend PRIVATE - _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE NDEBUG _REENTRANT + _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE _REENTRANT ENV_UNIX _7ZIP_LARGE_PAGES UNICODE _UNICODE UNIX_USE_WIN_FILE) endif() diff --git a/custom_widgets/CMakeLists.txt b/custom_widgets/CMakeLists.txt index 84590dad..4e35aa05 100644 --- a/custom_widgets/CMakeLists.txt +++ b/custom_widgets/CMakeLists.txt @@ -38,11 +38,15 @@ endif() # --- custom_widgets_reader (YACReader-specific) --- add_library(custom_widgets_reader STATIC ${WIDGETS_COMMON_SOURCES}) target_include_directories(custom_widgets_reader PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +yacreader_apply_build_options(custom_widgets_reader) # App-specific theme.h needed because themable.h → theme_manager.h → theme.h target_include_directories(custom_widgets_reader PRIVATE ${PROJECT_SOURCE_DIR}/YACReader/themes ) target_compile_definitions(custom_widgets_reader PRIVATE YACREADER) +if(BUILD_NUMBER) + target_compile_definitions(custom_widgets_reader PRIVATE "BUILD_NUMBER=\"${BUILD_NUMBER}\"") +endif() target_link_libraries(custom_widgets_reader PUBLIC Qt6::Core Qt6::Widgets @@ -83,6 +87,7 @@ add_library(custom_widgets_library STATIC ${LIBRARY_EXTRA_WIDGETS} ) target_include_directories(custom_widgets_library PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +yacreader_apply_build_options(custom_widgets_library) # App-specific theme.h + YACReaderLibrary headers needed by macosx_toolbar target_include_directories(custom_widgets_library PRIVATE ${PROJECT_SOURCE_DIR}/YACReaderLibrary/themes @@ -90,6 +95,9 @@ target_include_directories(custom_widgets_library PRIVATE ${PROJECT_SOURCE_DIR}/YACReaderLibrary/db ) target_compile_definitions(custom_widgets_library PRIVATE YACREADER_LIBRARY) +if(BUILD_NUMBER) + target_compile_definitions(custom_widgets_library PRIVATE "BUILD_NUMBER=\"${BUILD_NUMBER}\"") +endif() target_link_libraries(custom_widgets_library PUBLIC Qt6::Core Qt6::Widgets diff --git a/image_processing/CMakeLists.txt b/image_processing/CMakeLists.txt index 7421e7e1..86079aa4 100644 --- a/image_processing/CMakeLists.txt +++ b/image_processing/CMakeLists.txt @@ -5,5 +5,6 @@ add_library(image_processing STATIC ) target_include_directories(image_processing PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +yacreader_apply_build_options(image_processing) -target_link_libraries(image_processing PRIVATE Qt::Gui) +target_link_libraries(image_processing PRIVATE Qt6::Gui) diff --git a/shortcuts_management/CMakeLists.txt b/shortcuts_management/CMakeLists.txt index 3c893d06..88fab140 100644 --- a/shortcuts_management/CMakeLists.txt +++ b/shortcuts_management/CMakeLists.txt @@ -17,6 +17,7 @@ set(SHORTCUTS_SOURCES # --- shortcuts_reader (YACREADER define) --- add_library(shortcuts_reader STATIC ${SHORTCUTS_SOURCES}) target_include_directories(shortcuts_reader PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +yacreader_apply_build_options(shortcuts_reader) # App-specific theme.h needed because themable.h → theme_manager.h → theme.h target_include_directories(shortcuts_reader PRIVATE ${PROJECT_SOURCE_DIR}/YACReader/themes @@ -27,6 +28,7 @@ target_link_libraries(shortcuts_reader PUBLIC Qt6::Core Qt6::Widgets yr_global c # --- shortcuts_library (YACREADER_LIBRARY define) --- add_library(shortcuts_library STATIC ${SHORTCUTS_SOURCES}) target_include_directories(shortcuts_library PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +yacreader_apply_build_options(shortcuts_library) target_include_directories(shortcuts_library PRIVATE ${PROJECT_SOURCE_DIR}/YACReaderLibrary/themes ) diff --git a/tests/compressed_archive_test/CMakeLists.txt b/tests/compressed_archive_test/CMakeLists.txt index 4f0e1c47..ad7f4ac8 100644 --- a/tests/compressed_archive_test/CMakeLists.txt +++ b/tests/compressed_archive_test/CMakeLists.txt @@ -3,6 +3,7 @@ qt_add_executable(compressed_archive_test main.cpp ) +yacreader_apply_build_options(compressed_archive_test) target_link_libraries(compressed_archive_test PRIVATE Qt6::Core cbx_backend diff --git a/tests/concurrent_queue_test/CMakeLists.txt b/tests/concurrent_queue_test/CMakeLists.txt index 380e52b5..4df4df02 100644 --- a/tests/concurrent_queue_test/CMakeLists.txt +++ b/tests/concurrent_queue_test/CMakeLists.txt @@ -3,6 +3,7 @@ qt_add_executable(concurrent_queue_test concurrent_queue_test.cpp ) +yacreader_apply_build_options(concurrent_queue_test) target_link_libraries(concurrent_queue_test PRIVATE Qt6::Core Qt6::Test