From 37e6d114d9b8624e36ffd0bdc8e37ede32dc7678 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sat, 6 Jun 2026 01:03:09 +0200 Subject: cmake: upgrade cmake-common, introduce new features, etc. --- .github/workflows/ci.yml | 2 +- CMakeLists.txt | 13 +++++++++++-- Makefile | 6 +++--- aes/CMakeLists.txt | 8 ++++---- aesxx/CMakeLists.txt | 4 ++-- aesxx/utils/CMakeLists.txt | 25 ++++++++++++++++++++----- cmake | 2 +- 7 files changed, 42 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index af9a851..81b3a45 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,7 @@ jobs: PLATFORM: '${{ matrix.platform }}' CONFIGURATION: '${{ matrix.configuration }}' BOOST_VERSION: 1.81.0 - CMAKE_FLAGS: -D 'AES_TOOLS_ASM=${{ matrix.use_asm }}' + CMAKE_FLAGS: '--cmake-arg=-DAES_TOOLS_ASM=${{ matrix.use_asm }}' defaults: run: shell: pwsh diff --git a/CMakeLists.txt b/CMakeLists.txt index c86ea48..82b62c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,18 @@ -cmake_minimum_required(VERSION 3.8) +# oldstable as of May '26 +# Plus, I'm pretty sure it's required for things like CONFIGURE_DEPENDS and +# CMAKE_MSVC_RUNTIME_LIBRARY and stuff. +cmake_minimum_required(VERSION 3.25) project(aes_tools C CXX) enable_testing() -include(cmake/common.cmake) +if (MSVC) + add_compile_options(/MP /W4) +else() + add_compile_options(-Wall -Wextra) +endif() + +add_compile_definitions(WIN32_LEAN_AND_MEAN NOMINMAX) add_subdirectory(aes) add_subdirectory(aesxx) diff --git a/Makefile b/Makefile index ccabff5..2ce30df 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ TOOLSET ?= mingw PLATFORM ?= auto CONFIGURATION ?= Debug BOOST_VERSION ?= 1.72.0 -BOOST_LIBRARIES := --with-filesystem --with-program_options +BOOST_LIBRARIES := filesystem program_options CMAKE_FLAGS ?= INSTALL_PREFIX ?= $(install_dir) @@ -54,10 +54,10 @@ build: --configuration '$(call escape,$(CONFIGURATION))' \ --install '$(call escape,$(INSTALL_PREFIX))' \ --boost '$(call escape,$(boost_dir))' \ + $(CMAKE_FLAGS) \ -- \ '$(call escape,$(src_dir))' \ - '$(call escape,$(cmake_dir))' \ - $(CMAKE_FLAGS) + '$(call escape,$(cmake_dir))' .PHONY: install install: build diff --git a/aes/CMakeLists.txt b/aes/CMakeLists.txt index a19d3b7..e665b94 100644 --- a/aes/CMakeLists.txt +++ b/aes/CMakeLists.txt @@ -1,15 +1,15 @@ option(AES_TOOLS_ASM "Use the assembly language implementation instead of the one in C") -file(GLOB_RECURSE aes_include "include/*.h") -file(GLOB aes_src "src/*.c") +file(GLOB_RECURSE aes_include CONFIGURE_DEPENDS "include/*.h") +file(GLOB aes_src CONFIGURE_DEPENDS "src/*.c") if(MSVC AND AES_TOOLS_ASM) enable_language(ASM_MASM) - file(GLOB aes_src_impl "src/asm/*.asm") + file(GLOB aes_src_impl CONFIGURE_DEPENDS "src/asm/*.asm") set_source_files_properties(${aes_src_impl} PROPERTIES COMPILE_FLAGS /safeseh) # Setting CMAKE_ASM_MASM_FLAGS doesn't work: http://www.cmake.org/Bug/view.php?id=14711 else() - file(GLOB aes_src_impl "src/c/*.c") + file(GLOB aes_src_impl CONFIGURE_DEPENDS "src/c/*.c") endif() add_library(aes ${aes_include} ${aes_src} ${aes_src_impl}) diff --git a/aesxx/CMakeLists.txt b/aesxx/CMakeLists.txt index 0f814b8..378bad7 100644 --- a/aesxx/CMakeLists.txt +++ b/aesxx/CMakeLists.txt @@ -1,4 +1,4 @@ -find_package(Boost REQUIRED) +find_package(Boost CONFIG REQUIRED) add_library(aesxx INTERFACE) target_include_directories(aesxx INTERFACE include/) @@ -9,7 +9,7 @@ target_link_libraries(aesxx INTERFACE Boost::boost) if(MSVC_VERSION EQUAL 1900) - # These annoying DbgHelp.h warnings: + # These annoying dbghelp.h warnings: # https://connect.microsoft.com/VisualStudio/feedback/details/888527/warnings-on-dbghelp-h target_compile_options(aesxx INTERFACE /wd4091) endif() diff --git a/aesxx/utils/CMakeLists.txt b/aesxx/utils/CMakeLists.txt index 98b07f1..9ee06d0 100644 --- a/aesxx/utils/CMakeLists.txt +++ b/aesxx/utils/CMakeLists.txt @@ -1,20 +1,35 @@ -find_package(Boost REQUIRED COMPONENTS filesystem program_options) +find_package(Boost CONFIG REQUIRED COMPONENTS filesystem program_options) function(add_util name src) set(target "util_${name}") add_executable("${target}" ${src}) - target_link_libraries("${target}" PRIVATE aesxx Boost::disable_autolinking Boost::filesystem Boost::program_options) + target_link_libraries("${target}" PRIVATE + aesxx + Boost::disable_autolinking + Boost::filesystem + Boost::program_options) set_target_properties("${target}" PROPERTIES OUTPUT_NAME "${name}") install(TARGETS "${target}" RUNTIME DESTINATION bin) - install_pdbs(TARGETS "${target}" DESTINATION bin) + if(MSVC) + install(FILES "$" DESTINATION bin OPTIONAL) + endif() endfunction() -set(block_util_headers block_cmd_parser.hpp block_dumper.hpp block_input.hpp data_parsers.hpp helpers/command_line.hpp) +set(block_util_headers + block_cmd_parser.hpp + block_dumper.hpp + block_input.hpp + data_parsers.hpp + helpers/command_line.hpp) add_util(encrypt_block encrypt_block.cpp ${block_util_headers}) add_util(decrypt_block decrypt_block.cpp ${block_util_headers}) -set(file_util_headers data_parsers.hpp file_cmd_parser.hpp helpers/command_line.hpp helpers/file.hpp) +set(file_util_headers + data_parsers.hpp + file_cmd_parser.hpp + helpers/command_line.hpp + helpers/file.hpp) add_util(encrypt_file encrypt_file.cpp ${file_util_headers}) add_util(decrypt_file decrypt_file.cpp ${file_util_headers}) diff --git a/cmake b/cmake index 9e7304a..899a49f 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit 9e7304af2fe5a4f89da64ac76768697aac4f858e +Subproject commit 899a49f46c62aaebdc2f0988496c493f0963248b -- cgit v1.3