From 914d21de58094d461c9f86738136fb034a691113 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 22 Sep 2022 09:22:37 -0400 Subject: bootstrap: Enable add_compile_definitions command Make the command available to CMake's own CMake code. --- Source/cmCommands.cxx | 4 ++-- bootstrap | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 3bc4f0e..27f2156 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -225,6 +225,8 @@ void GetScriptingCommands(cmState* state) void GetProjectCommands(cmState* state) { + state->AddBuiltinCommand("add_compile_definitions", + cmAddCompileDefinitionsCommand); state->AddBuiltinCommand("add_custom_command", cmAddCustomCommandCommand); state->AddBuiltinCommand("add_custom_target", cmAddCustomTargetCommand); state->AddBuiltinCommand("add_definitions", cmAddDefinitionsCommand); @@ -275,8 +277,6 @@ void GetProjectCommands(cmState* state) cmTargetPrecompileHeadersCommand); #if !defined(CMAKE_BOOTSTRAP) - state->AddBuiltinCommand("add_compile_definitions", - cmAddCompileDefinitionsCommand); state->AddBuiltinCommand("add_compile_options", cmAddCompileOptionsCommand); state->AddBuiltinCommand("aux_source_directory", cmAuxSourceDirectoryCommand); diff --git a/bootstrap b/bootstrap index d5b071e..a79aeae 100755 --- a/bootstrap +++ b/bootstrap @@ -281,6 +281,7 @@ CMAKE_UNUSED_SOURCES="\ " CMAKE_CXX_SOURCES="\ + cmAddCompileDefinitionsCommand \ cmAddCustomCommandCommand \ cmAddCustomTargetCommand \ cmAddDefinitionsCommand \ -- cgit v0.12 From a509602699eb83fbbea67244051c8a18f708a6ae Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 02:00:05 +0400 Subject: Build: Modernize some `foreach` calls to use `IN LISTS`/`IN ITEMS` --- CMakeLists.txt | 16 +-- CompileFlags.cmake | 6 +- Source/CMakeLists.txt | 11 +-- Source/QtDialog/CMakeLists.txt | 8 +- Tests/CMakeLib/PseudoMemcheck/CMakeLists.txt | 4 +- Tests/CMakeLists.txt | 140 +++++++++++++-------------- Tests/CTestUpdateCommon.cmake | 6 +- Tests/CTestUpdateP4.cmake.in | 6 +- Tests/EnforceConfig.cmake.in | 2 +- Tests/RunCMake/CMakeLists.txt | 8 +- Tests/RunCMake/RunCMake.cmake | 10 +- Tests/VSGNUFortran/CMakeLists.txt | 2 +- Tests/VSWinStorePhone/VerifyAppPackage.cmake | 2 +- Utilities/Sphinx/CMakeLists.txt | 12 +-- 14 files changed, 114 insertions(+), 119 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d77dfc..3d26ba9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,8 +17,8 @@ unset(CMAKE_USER_MAKE_RULES_OVERRIDE_C) if(MSVC AND NOT CMAKE_VERSION VERSION_LESS 3.15) # Filter out MSVC runtime library flags that may have come from # the cache of an existing build tree or from scripts. - foreach(l C CXX) - foreach(c DEBUG MINSIZEREL RELEASE RELWITHDEBINFO) + foreach(l IN ITEMS C CXX) + foreach(c IN ITEMS DEBUG MINSIZEREL RELEASE RELWITHDEBINFO) string(REGEX REPLACE "[-/]M[DT]d?( |$)" "" "CMAKE_${l}_FLAGS_${c}" "${CMAKE_${l}_FLAGS_${c}}") endforeach() endforeach() @@ -165,7 +165,7 @@ macro(CMAKE_HANDLE_SYSTEM_LIBRARIES) # Allow the user to enable/disable all system utility library options by # defining CMAKE_USE_SYSTEM_LIBRARIES or CMAKE_USE_SYSTEM_LIBRARY_${util}. set(UTILITIES BZIP2 CURL EXPAT FORM JSONCPP LIBARCHIVE LIBLZMA LIBRHASH LIBUV NGHTTP2 ZLIB ZSTD) - foreach(util ${UTILITIES}) + foreach(util IN LISTS UTILITIES) if(NOT DEFINED CMAKE_USE_SYSTEM_LIBRARY_${util} AND DEFINED CMAKE_USE_SYSTEM_LIBRARIES) set(CMAKE_USE_SYSTEM_LIBRARY_${util} "${CMAKE_USE_SYSTEM_LIBRARIES}") @@ -215,7 +215,7 @@ macro(CMAKE_HANDLE_SYSTEM_LIBRARIES) mark_as_advanced(CMAKE_USE_SYSTEM_KWIML) # Mention to the user what system libraries are being used. - foreach(util ${UTILITIES} KWIML) + foreach(util IN LISTS UTILITIES ITEMS KWIML) if(CMAKE_USE_SYSTEM_${util}) message(STATUS "Using system-installed ${util}") endif() @@ -235,7 +235,7 @@ endmacro() macro(CMAKE_SETUP_TESTING) if(BUILD_TESTING) set(CMAKE_TEST_SYSTEM_LIBRARIES 0) - foreach(util CURL EXPAT ZLIB) + foreach(util IN ITEMS CURL EXPAT ZLIB) if(CMAKE_USE_SYSTEM_${util}) set(CMAKE_TEST_SYSTEM_LIBRARIES 1) endif() @@ -250,7 +250,7 @@ macro(CMAKE_SETUP_TESTING) set(CMAKE_CTEST_COMMAND "${CMake_TEST_EXTERNAL_CMAKE}/ctest") set(CMAKE_CMAKE_COMMAND "${CMake_TEST_EXTERNAL_CMAKE}/cmake") set(CMAKE_CPACK_COMMAND "${CMake_TEST_EXTERNAL_CMAKE}/cpack") - foreach(exe cmake ctest cpack) + foreach(exe IN ITEMS cmake ctest cpack) add_executable(${exe} IMPORTED) set_property(TARGET ${exe} PROPERTY IMPORTED_LOCATION ${CMake_TEST_EXTERNAL_CMAKE}/${exe}) endforeach() @@ -860,8 +860,8 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE) -Wshadow -Wpointer-arith -Wformat-security -Wundef ) - foreach(FLAG_LANG C CXX) - foreach(FLAG ${${FLAG_LANG}_FLAGS_LIST}) + foreach(FLAG_LANG IN ITEMS C CXX) + foreach(FLAG IN LISTS ${FLAG_LANG}_FLAGS_LIST) if(NOT " ${CMAKE_${FLAG_LANG}_FLAGS} " MATCHES " ${FLAG} ") set(CMAKE_${FLAG_LANG}_FLAGS "${CMAKE_${FLAG_LANG}_FLAGS} ${FLAG}") endif() diff --git a/CompileFlags.cmake b/CompileFlags.cmake index 47c8352..acfa29f 100644 --- a/CompileFlags.cmake +++ b/CompileFlags.cmake @@ -98,7 +98,7 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL SunPro AND endif() endif() -foreach(lang C CXX) +foreach(lang IN ITEMS C CXX) # Suppress warnings from PGI compiler. if (CMAKE_${lang}_COMPILER_ID STREQUAL "PGI") set(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} -w") @@ -138,9 +138,9 @@ OFF to disable /MP completely." ) endif() # Get rid of excess -Wunused-but-set-variable on release builds with LCC >= 1.26 -foreach(l C CXX) +foreach(l IN ITEMS C CXX) if(CMAKE_${l}_COMPILER_ID STREQUAL "LCC" AND NOT CMAKE_${l}_COMPILER_VERSION VERSION_LESS 1.26) - foreach(c MINSIZEREL RELEASE RELWITHDEBINFO) + foreach(c IN ITEMS MINSIZEREL RELEASE RELWITHDEBINFO) string(APPEND "CMAKE_${l}_FLAGS_${c}" " -Wno-unused-but-set-variable") endforeach() endif() diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 86f8116..8f4750e 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -881,16 +881,13 @@ if(WIN32 AND NOT CYGWIN) target_link_libraries(cmcldeps CMakeLib) endif() -foreach(v CURL_CA_BUNDLE CURL_CA_PATH) +foreach(v IN ITEMS CURL_CA_BUNDLE CURL_CA_PATH) if(${v}) set_property(SOURCE cmCurl.cxx APPEND PROPERTY COMPILE_DEFINITIONS ${v}="${${v}}") endif() endforeach() -foreach(check - STAT_HAS_ST_MTIM - STAT_HAS_ST_MTIMESPEC - ) +foreach(check IN ITEMS STAT_HAS_ST_MTIM STAT_HAS_ST_MTIMESPEC) if(KWSYS_CXX_${check}_COMPILED) # abuse KWSys check cache entry set(CMake_${check} 1) else() @@ -1217,7 +1214,7 @@ if(WIN32) # MinGW's windres tool with spaces in the path to the include directories. add_library(CMakeVersion OBJECT "${CMAKE_CURRENT_BINARY_DIR}/CMakeVersion.rc") set_property(TARGET CMakeVersion PROPERTY INCLUDE_DIRECTORIES "") - foreach(_tool ${_tools}) + foreach(_tool IN LISTS _tools) target_sources(${_tool} PRIVATE $) endforeach() endif() @@ -1229,7 +1226,7 @@ endif() # Install tools -foreach(_tool ${_tools}) +foreach(_tool IN LISTS _tools) CMake_OPTIONAL_COMPONENT(${_tool}) install(TARGETS ${_tool} DESTINATION ${CMAKE_BIN_DIR} ${COMPONENT}) endforeach() diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index 0c263bb..9b6007c 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -100,13 +100,13 @@ if(CMake_INSTALL_DEPENDENCIES AND (APPLE OR WIN32)) endif() endmacro() macro(install_qt_plugins _comps _plugins_var) - foreach(_qt_comp ${${_comps}}) + foreach(_qt_comp IN LISTS ${_comps}) if (INSTALLED_QT_VERSION VERSION_LESS 6) set(_qt_module_plugins ${Qt${INSTALLED_QT_VERSION}${_qt_comp}_PLUGINS}) else() get_target_property(_qt_module_plugins Qt${INSTALLED_QT_VERSION}::${_qt_comp} QT_PLUGINS) endif() - foreach(_qt_plugin ${_qt_module_plugins}) + foreach(_qt_plugin IN LISTS _qt_module_plugins) if (INSTALLED_QT_VERSION VERSION_GREATER_EQUAL 6) # Qt6 provides the plugins as individual packages that need to be found. find_package(Qt${INSTALLED_QT_VERSION}${_qt_plugin} QUIET @@ -308,13 +308,13 @@ install(TARGETS cmake-gui ${CMAKE_INSTALL_DESTINATION_ARGS}) if(UNIX AND NOT APPLE) - foreach (size IN ITEMS 32 128) + foreach(size IN ITEMS 32 128) install( FILES "${CMAKE_CURRENT_SOURCE_DIR}/CMakeSetup${size}.png" DESTINATION "${CMAKE_XDGDATA_DIR}/icons/hicolor/${size}x${size}/apps" ${COMPONENT} RENAME "CMakeSetup.png") - endforeach () + endforeach() # install a desktop file so CMake appears in the application start menu # with an icon diff --git a/Tests/CMakeLib/PseudoMemcheck/CMakeLists.txt b/Tests/CMakeLib/PseudoMemcheck/CMakeLists.txt index 4bef6c5..3f2f891 100644 --- a/Tests/CMakeLib/PseudoMemcheck/CMakeLists.txt +++ b/Tests/CMakeLib/PseudoMemcheck/CMakeLists.txt @@ -1,6 +1,6 @@ -foreach (_retval 0 1) +foreach(_retval IN ITEMS 0 1) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/memtester.cxx.in" "${CMAKE_CURRENT_BINARY_DIR}/ret${_retval}.cxx" @ONLY) -endforeach () +endforeach() include_directories(${CMake_SOURCE_DIR}/Source ${CMake_BINARY_DIR}/Source) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index abe742e..24a7c88 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -205,7 +205,7 @@ if(BUILD_TESTING) select_wince_sdk(reg_wince wince_sdk) set(reg_tegra "[HKEY_LOCAL_MACHINE\\SOFTWARE\\NVIDIA Corporation\\Nsight Tegra;sdkRoot]") set(reg_nasm "[HKEY_CURRENT_USER\\SOFTWARE\\nasm]") - foreach(reg vs10 vs11 vs12 vs14 ws80 ws81 ws10_0 wp80 wp81 wince tegra nasm) + foreach(reg IN ITEMS vs10 vs11 vs12 vs14 ws80 ws81 ws10_0 wp80 wp81 wince tegra nasm) get_filename_component(r "${reg_${reg}}" ABSOLUTE) if(IS_DIRECTORY "${r}" AND NOT "${r}" STREQUAL "/registry") set(${reg} 1) @@ -227,7 +227,7 @@ if(BUILD_TESTING) set(vs_versions vs15) endif() endif() - foreach(info ${vs_versions}) + foreach(info IN LISTS vs_versions) cmake_host_system_information(RESULT found QUERY "${info_${info}}") if(found) set(${info} 1) @@ -730,13 +730,15 @@ if(BUILD_TESTING) # mainly it tests that cmake doesn't crash when generating these project files. if(CMAKE_GENERATOR MATCHES "^(Unix Makefiles|Ninja)$" AND NOT "${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") - foreach(extraGenerator + foreach( + extraGenerator + IN ITEMS "CodeBlocks" "CodeLite" "Eclipse CDT4" "Kate" "Sublime Text 2" - ) + ) string(REPLACE " " "" extraGeneratorTestName "Simple_${extraGenerator}Generator") add_test(${extraGeneratorTestName} ${CMAKE_CTEST_COMMAND} --build-and-test @@ -1127,7 +1129,7 @@ if(BUILD_TESTING) set(CPACK_GENERATOR_STRING_${CPackGen} ${CPackGen}) endif() set(CPackRun_CPackGen "-DCPackGen=${CPACK_GENERATOR_STRING_${CPackGen}}") - foreach(CPackComponentWay ${CWAYLST}) + foreach(CPackComponentWay IN LISTS CWAYLST) set(CPackRun_CPackComponentWay "-DCPackComponentWay=${CPackComponentWay}") add_test(CPackComponentsForAll-${CPackGen}-${CPackComponentWay} ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} @@ -1433,64 +1435,66 @@ if(BUILD_TESTING) endif() # test for Find modules, simple cases - foreach(_mod IN ITEMS - ALSA - Boost - BLAS - BZip2 - CURL - Cups - Doxygen - DevIL - EnvModules - EXPAT - Fontconfig - Freetype - GDAL - GIF - Git - GLEW - GLUT - GnuTLS - GSL - GTK2 - Iconv - ICU - Intl - Jasper - JNI - JPEG - JsonCpp - LAPACK - LibArchive - LibLZMA - LibRHash - Libinput - LibUV - LibXml2 - LibXslt - LTTngUST - ODBC - OpenACC - OpenAL - OpenCL - OpenGL - OpenMP - OpenSP - OpenSSL - MPI - PNG - Patch - PostgreSQL - Protobuf - SDL - SQLite3 - TIFF - Vulkan - X11 - XalanC - XercesC - ) + foreach( + _mod + IN ITEMS + ALSA + BLAS + Boost + BZip2 + Cups + CURL + DevIL + Doxygen + EnvModules + EXPAT + Fontconfig + Freetype + GDAL + GIF + Git + GLEW + GLUT + GnuTLS + GSL + GTK2 + Iconv + ICU + Intl + Jasper + JNI + JPEG + JsonCpp + LAPACK + LibArchive + Libinput + LibLZMA + LibRHash + LibUV + LibXml2 + LibXslt + LTTngUST + MPI + ODBC + OpenACC + OpenAL + OpenCL + OpenGL + OpenMP + OpenSP + OpenSSL + Patch + PNG + PostgreSQL + Protobuf + SDL + SQLite3 + TIFF + Vulkan + X11 + XalanC + XercesC + ) if(CMake_TEST_Find${_mod}) add_subdirectory(Find${_mod}) endif() @@ -1570,7 +1574,7 @@ if(BUILD_TESTING) endif() set(ExternalProject_BUILD_OPTIONS "") - foreach(vcs CVS SVN GIT HG) + foreach(vcs IN ITEMS CVS SVN GIT HG) if(DEFINED CMake_TEST_ExternalProject_${vcs}) list(APPEND ExternalProject_BUILD_OPTIONS -DEP_TEST_${vcs}=${CMake_TEST_ExternalProject_${vcs}}) endif() @@ -2179,7 +2183,7 @@ if(BUILD_TESTING) # The test (and tested property) works with .sln files, so it's skipped when: # * cmake --build is set up to use MSBuild, since the MSBuild invocation does not use the .sln file set(_last_test "") - foreach(config ${CMAKE_CONFIGURATION_TYPES}) + foreach(config IN LISTS CMAKE_CONFIGURATION_TYPES) add_test(NAME VSExcludeFromDefaultBuild-${config} COMMAND ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/VSExcludeFromDefaultBuild" @@ -3539,11 +3543,7 @@ if(BUILD_TESTING) # The directory should also contain a Configure.cmake file that # sets "CMake_TEST_CONTRACT__" variables to configure # the code below. - foreach(project - PLplot - Trilinos - VTK - ) + foreach(project IN ITEMS PLplot Trilinos VTK) if(CMake_TEST_CONTRACT_${project}) include(Contracts/${project}/Configure.cmake) ADD_TEST_MACRO(Contracts.${project} ${CMake_TEST_CONTRACT_${project}_RUN_TEST}) diff --git a/Tests/CTestUpdateCommon.cmake b/Tests/CTestUpdateCommon.cmake index 0f8ec8e..467b41a 100644 --- a/Tests/CTestUpdateCommon.cmake +++ b/Tests/CTestUpdateCommon.cmake @@ -73,7 +73,7 @@ function(check_updates build) string(REGEX REPLACE "${rev_regex}" "\\1" element "${r}") set(element_${element} 1) endforeach() - foreach(element ${rev_elements}) + foreach(element IN LISTS rev_elements) if(NOT element_${element}) list(APPEND MISSING "global <${element}> element") endif() @@ -85,7 +85,7 @@ function(check_updates build) if(MISSING) # List the missing entries string(APPEND MSG "Update.xml is missing expected entries:\n") - foreach(f ${MISSING}) + foreach(f IN LISTS MISSING) string(APPEND MSG " ${f}\n") endforeach() else() @@ -97,7 +97,7 @@ function(check_updates build) if(EXTRA) # List the extra entries string(APPEND MSG "Update.xml has extra unexpected entries:\n") - foreach(f ${EXTRA}) + foreach(f IN LISTS EXTRA) string(APPEND MSG " ${f}\n") endforeach() else() diff --git a/Tests/CTestUpdateP4.cmake.in b/Tests/CTestUpdateP4.cmake.in index 8a99e67..2ac01e2 100644 --- a/Tests/CTestUpdateP4.cmake.in +++ b/Tests/CTestUpdateP4.cmake.in @@ -109,7 +109,7 @@ list(APPEND P4CMD ${P4_CLIENT}) message("Adding files to repository") file(GLOB_RECURSE files ${TOP}/user-source/*) -foreach(filename ${files}) +foreach(filename IN LISTS files) run_child( WORKING_DIRECTORY ${TOP}/user-source COMMAND ${P4CMD} add ${filename} @@ -140,14 +140,14 @@ run_child( # Make changes in the working tree. message("Changing content...") update_content(user-source files_added files_removed dirs_added) -foreach(filename ${files_added}) +foreach(filename IN LISTS files_added) message("add: ${filename}") run_child( WORKING_DIRECTORY ${TOP}/user-source COMMAND ${P4CMD} add ${TOP}/user-source/${filename} ) endforeach() -foreach(filename ${files_removed}) +foreach(filename IN LISTS files_removed) run_child( WORKING_DIRECTORY ${TOP}/user-source COMMAND ${P4CMD} delete ${TOP}/user-source/${filename} diff --git a/Tests/EnforceConfig.cmake.in b/Tests/EnforceConfig.cmake.in index 7c6f76a..10f8461 100644 --- a/Tests/EnforceConfig.cmake.in +++ b/Tests/EnforceConfig.cmake.in @@ -10,7 +10,7 @@ if(NOT CTEST_CONFIGURATION_TYPE) set(CTEST_CMD "@CMAKE_CTEST_COMMAND@@CMAKE_EXECUTABLE_SUFFIX@") get_filename_component(CTEST_DIR "${CTEST_CMD}" PATH) get_filename_component(CTEST_EXE "${CTEST_CMD}" NAME) - foreach(cfg Release Debug MinSizeRel RelWithDebInfo) + foreach(cfg IN ITEMS Release Debug MinSizeRel RelWithDebInfo) if(NOT CTEST_CONFIGURATION_TYPE) if(EXISTS "${CTEST_DIR}/${cfg}/${CTEST_EXE}") set(CTEST_CONFIGURATION_TYPE ${cfg}) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index db4200b..1d7cccf 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -527,7 +527,9 @@ function(add_RunCMake_test_try_compile) set(CMAKE_CXX_STANDARD_DEFAULT 14) endif() endif() - foreach(var + foreach( + var + IN ITEMS CMAKE_SYSTEM_NAME CMAKE_C_COMPILER_ID CMAKE_C_COMPILER_VERSION @@ -541,7 +543,7 @@ function(add_RunCMake_test_try_compile) CMake_TEST_FILESYSTEM_1S CMAKE_OBJC_STANDARD_DEFAULT CMAKE_OBJCXX_STANDARD_DEFAULT - ) + ) if(DEFINED ${var}) list(APPEND try_compile_ARGS -D${var}=${${var}}) endif() @@ -956,7 +958,7 @@ if(CMake_TEST_ANDROID_NDK OR CMake_TEST_ANDROID_STANDALONE_TOOLCHAIN) if(NOT "${CMAKE_GENERATOR}" MATCHES "Make|Ninja|Visual Studio 1[456]") message(FATAL_ERROR "Android tests supported only by Makefile, Ninja, and Visual Studio >= 14 generators") endif() - foreach(v TEST_ANDROID_NDK TEST_ANDROID_STANDALONE_TOOLCHAIN) + foreach(v IN ITEMS TEST_ANDROID_NDK TEST_ANDROID_STANDALONE_TOOLCHAIN) if(CMake_${v}) string(REPLACE ";" "|" ${v} "${CMake_${v}}") list(APPEND Android_ARGS "-D${v}=${${v}}") diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index 1c92ca0..c329b46 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -1,8 +1,10 @@ -foreach(arg +foreach( + arg + IN ITEMS RunCMake_GENERATOR RunCMake_SOURCE_DIR RunCMake_BINARY_DIR - ) + ) if(NOT DEFINED ${arg}) message(FATAL_ERROR "${arg} not given!") endif() @@ -31,7 +33,7 @@ function(run_cmake test) set(platform_name msys) endif() - foreach(o out err) + foreach(o IN ITEMS out err) if(RunCMake-std${o}-file AND EXISTS ${top_src}/${RunCMake-std${o}-file}) file(READ ${top_src}/${RunCMake-std${o}-file} expect_std${o}) string(REGEX REPLACE "\n+$" "" expect_std${o} "${expect_std${o}}") @@ -176,7 +178,7 @@ function(run_cmake test) "|[^\n]*Bullseye Testing Technology" ")[^\n]*\n)+" ) - foreach(o out err) + foreach(o IN ITEMS out err) string(REGEX REPLACE "\r\n" "\n" actual_std${o} "${actual_std${o}}") string(REGEX REPLACE "${ignore_line_regex}" "\\1" actual_std${o} "${actual_std${o}}") string(REGEX REPLACE "\n+$" "" actual_std${o} "${actual_std${o}}") diff --git a/Tests/VSGNUFortran/CMakeLists.txt b/Tests/VSGNUFortran/CMakeLists.txt index 993d0d6..2b4f4fa 100644 --- a/Tests/VSGNUFortran/CMakeLists.txt +++ b/Tests/VSGNUFortran/CMakeLists.txt @@ -11,7 +11,7 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") # to be in the same directory. get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(_isMultiConfig) - foreach(config ${CMAKE_CONFIGURATION_TYPES}) + foreach(config IN LISTS CMAKE_CONFIGURATION_TYPES) string(TOUPPER "${config}" config) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${config} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) diff --git a/Tests/VSWinStorePhone/VerifyAppPackage.cmake b/Tests/VSWinStorePhone/VerifyAppPackage.cmake index f9440d7..52e8a54 100644 --- a/Tests/VSWinStorePhone/VerifyAppPackage.cmake +++ b/Tests/VSWinStorePhone/VerifyAppPackage.cmake @@ -26,7 +26,7 @@ if(NOT result EQUAL 0) message(FATAL_ERROR "Listing app package content failed with: ${error}") endif() -foreach(app_pkg_item ${EXPECTED_APP_PKG_CONTENT}) +foreach(app_pkg_item IN LISTS EXPECTED_APP_PKG_CONTENT) string(FIND ${APP_PKG_CONTENT_OUTPUT} ${app_pkg_item} _found) if(_found EQUAL -1) message(FATAL_ERROR "Generated app package is missing an expected item: ${app_pkg_item}") diff --git a/Utilities/Sphinx/CMakeLists.txt b/Utilities/Sphinx/CMakeLists.txt index ffca624..886f4e0 100644 --- a/Utilities/Sphinx/CMakeLists.txt +++ b/Utilities/Sphinx/CMakeLists.txt @@ -161,7 +161,7 @@ endif() set(doc_format_outputs "") set(doc_format_last "") -foreach(format ${doc_formats}) +foreach(format IN LISTS doc_formats) set(doc_format_output "doc_format_${format}") set(doc_format_log "build-${format}.log") if(CMake_SPHINX_CMAKE_ORG) @@ -219,13 +219,7 @@ endforeach() add_custom_target(documentation ALL DEPENDS ${doc_format_outputs}) if(CMake_SPHINX_DEPEND_ON_EXECUTABLES) - foreach(t - cmake - ccmake - cmake-gui - cpack - ctest - ) + foreach(t IN ITEMS cmake ccmake cmake-gui cpack ctest) if(TARGET ${t}) # Build documentation after main executables. add_dependencies(documentation ${t}) @@ -248,7 +242,7 @@ endif() if(SPHINX_MAN) file(GLOB man_rst RELATIVE ${CMake_SOURCE_DIR}/Help/manual ${CMake_SOURCE_DIR}/Help/manual/*.[1-9].rst) - foreach(m ${man_rst}) + foreach(m IN LISTS man_rst) if("x${m}" MATCHES "^x(.+)\\.([1-9])\\.rst$") set(name "${CMAKE_MATCH_1}") set(sec "${CMAKE_MATCH_2}") -- cgit v0.12 From dd28d76203aa3c4745b518a8b9bae7e7bb70b70d Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 02:26:22 +0400 Subject: CMakeLists: Remove redundant spaces around CMake command calls --- CMakeLists.txt | 25 ++++----- Source/CMakeLists.txt | 12 ++--- Source/QtDialog/CMakeLists.txt | 20 ++++---- Tests/CMakeLists.txt | 112 ++++++++++++++++++++--------------------- 4 files changed, 85 insertions(+), 84 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d26ba9..00e0052 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,7 +81,7 @@ if(NOT DEFINED CMAKE_C_STANDARD AND NOT CMake_NO_C_STANDARD) endif() endif() if(NOT DEFINED CMAKE_CXX_STANDARD AND NOT CMake_NO_CXX_STANDARD) - if (CMAKE_CXX_COMPILER_ID STREQUAL SunPro AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.14) + if(CMAKE_CXX_COMPILER_ID STREQUAL SunPro AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.14) set(CMAKE_CXX_STANDARD 98) else() if(NOT CMAKE_VERSION VERSION_LESS 3.8) @@ -143,7 +143,7 @@ option(CMake_BUILD_DEVELOPER_REFERENCE mark_as_advanced(CMake_BUILD_DEVELOPER_REFERENCE) # option to build using interprocedural optimizations (IPO/LTO) -if (NOT CMAKE_VERSION VERSION_LESS 3.12.2) +if(NOT CMAKE_VERSION VERSION_LESS 3.12.2) option(CMake_BUILD_LTO "Compile CMake with link-time optimization if supported" OFF) if(CMake_BUILD_LTO) include(CheckIPOSupported) @@ -344,7 +344,7 @@ endmacro() # a macro to build the utilities used by CMake # Simply to improve readability of the main script. #----------------------------------------------------------------------- -macro (CMAKE_BUILD_UTILITIES) +macro(CMAKE_BUILD_UTILITIES) find_package(Threads) # Suppress unnecessary checks in third-party code. @@ -400,7 +400,7 @@ macro (CMAKE_BUILD_UTILITIES) # Setup third-party libraries. # Everything in the tree should be able to include files from the # Utilities directory. - if ((CMAKE_SYSTEM_NAME STREQUAL "AIX" OR CMAKE_SYSTEM_NAME STREQUAL "OS400") AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + if((CMAKE_SYSTEM_NAME STREQUAL "AIX" OR CMAKE_SYSTEM_NAME STREQUAL "OS400") AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # using -isystem option generate error "template with C linkage" include_directories("${CMake_SOURCE_DIR}/Utilities/std") else() @@ -408,7 +408,7 @@ macro (CMAKE_BUILD_UTILITIES) endif() include_directories("${CMake_BINARY_DIR}/Utilities") - if ((CMAKE_SYSTEM_NAME STREQUAL "AIX" OR CMAKE_SYSTEM_NAME STREQUAL "OS400") AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + if((CMAKE_SYSTEM_NAME STREQUAL "AIX" OR CMAKE_SYSTEM_NAME STREQUAL "OS400") AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # using -isystem option generate error "template with C linkage" include_directories("${CMake_SOURCE_DIR}/Utilities") else() @@ -686,14 +686,14 @@ macro (CMAKE_BUILD_UTILITIES) #--------------------------------------------------------------------- # Use curses? if(NOT DEFINED BUILD_CursesDialog) - if (UNIX) + if(UNIX) include(${CMake_SOURCE_DIR}/Source/Checks/Curses.cmake) set(BUILD_CursesDialog_DEFAULT "${CMakeCheckCurses_COMPILED}") elseif(WIN32) set(BUILD_CursesDialog_DEFAULT "OFF") endif() option(BUILD_CursesDialog "Build the CMake Curses Dialog ccmake" "${BUILD_CursesDialog_DEFAULT}") - endif () + endif() if(BUILD_CursesDialog) if(UNIX) set(CURSES_NEED_NCURSES TRUE) @@ -718,10 +718,10 @@ macro (CMAKE_BUILD_UTILITIES) if(NOT CMAKE_USE_SYSTEM_FORM) add_subdirectory(Source/CursesDialog/form) elseif(NOT CURSES_FORM_LIBRARY) - message( FATAL_ERROR "CMAKE_USE_SYSTEM_FORM in ON but CURSES_FORM_LIBRARY is not set!" ) + message(FATAL_ERROR "CMAKE_USE_SYSTEM_FORM in ON but CURSES_FORM_LIBRARY is not set!") endif() endif() -endmacro () +endmacro() #----------------------------------------------------------------------- if(NOT CMake_TEST_EXTERNAL_CMAKE) @@ -749,7 +749,7 @@ include(Source/CMakeVersion.cmake) # Include the standard Dart testing module enable_testing() -include (${CMAKE_ROOT}/Modules/Dart.cmake) +include(${CMAKE_ROOT}/Modules/Dart.cmake) # Set up test-time configuration. set_directory_properties(PROPERTIES @@ -836,7 +836,7 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE) add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") - include (CMakeCPack.cmake) + include(CMakeCPack.cmake) endif() @@ -891,7 +891,8 @@ endif() if(BUILD_TESTING) add_test(SystemInformationNew "${CMAKE_CMAKE_COMMAND}" - --system-information -G "${CMAKE_GENERATOR}" ) + --system-information -G "${CMAKE_GENERATOR}" + ) endif() if(NOT CMake_TEST_EXTERNAL_CMAKE) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 8f4750e..b1a79af 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -4,7 +4,7 @@ # To ensure maximum portability across various compilers and platforms # deactivate any compiler extensions. Skip this for QNX, where additional # work is needed to build without compiler extensions. -if (NOT CMAKE_SYSTEM_NAME STREQUAL "QNX") +if(NOT CMAKE_SYSTEM_NAME STREQUAL "QNX") set(CMAKE_C_EXTENSIONS FALSE) set(CMAKE_CXX_EXTENSIONS FALSE) endif() @@ -760,7 +760,7 @@ if(APPLE) endif() -if (WIN32) +if(WIN32) set(SRCS ${SRCS} cmCallVisualStudioMacro.cxx cmCallVisualStudioMacro.h @@ -824,7 +824,7 @@ if (WIN32) # GetVersion to work properly on Windows 8 and above. set(MANIFEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/cmake.version.manifest) endif() -endif () +endif() # Watcom support if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin") @@ -1084,7 +1084,7 @@ if(UNIX) endif() endif() - if (NOT FREEBSD_PKG_INCLUDE_DIRS OR NOT FREEBSD_PKG_LIBRARIES) + if(NOT FREEBSD_PKG_INCLUDE_DIRS OR NOT FREEBSD_PKG_LIBRARIES) message(FATAL_ERROR "CPack needs libpkg(3) to produce FreeBSD packages natively.") endif() else() @@ -1188,8 +1188,8 @@ if(BUILD_QtDialog) add_subdirectory(QtDialog) endif() -include (${CMake_BINARY_DIR}/Source/LocalUserOptions.cmake OPTIONAL) -include (${CMake_SOURCE_DIR}/Source/LocalUserOptions.cmake OPTIONAL) +include(${CMake_BINARY_DIR}/Source/LocalUserOptions.cmake OPTIONAL) +include(${CMake_SOURCE_DIR}/Source/LocalUserOptions.cmake OPTIONAL) if(WIN32) # Compute the binary version that appears in the RC file. Version diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index 9b6007c..95962d8 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -3,7 +3,7 @@ project(QtDialog) CMake_OPTIONAL_COMPONENT(cmake-gui) -set (QT_COMPONENTS +set(QT_COMPONENTS Core Widgets Gui @@ -41,7 +41,7 @@ set(CMake_QT_EXTRA_LIBRARIES) # Try to find the package WinExtras for the task bar progress if(WIN32) find_package(Qt${INSTALLED_QT_VERSION}WinExtras QUIET) - if (Qt${INSTALLED_QT_VERSION}WinExtras_FOUND) + if(Qt${INSTALLED_QT_VERSION}WinExtras_FOUND) add_definitions(-DQT_WINEXTRAS) list(APPEND CMake_QT_EXTRA_LIBRARIES Qt${INSTALLED_QT_VERSION}::WinExtras) list(APPEND QT_COMPONENTS WinExtras) @@ -101,13 +101,13 @@ if(CMake_INSTALL_DEPENDENCIES AND (APPLE OR WIN32)) endmacro() macro(install_qt_plugins _comps _plugins_var) foreach(_qt_comp IN LISTS ${_comps}) - if (INSTALLED_QT_VERSION VERSION_LESS 6) + if(INSTALLED_QT_VERSION VERSION_LESS 6) set(_qt_module_plugins ${Qt${INSTALLED_QT_VERSION}${_qt_comp}_PLUGINS}) else() get_target_property(_qt_module_plugins Qt${INSTALLED_QT_VERSION}::${_qt_comp} QT_PLUGINS) endif() foreach(_qt_plugin IN LISTS _qt_module_plugins) - if (INSTALLED_QT_VERSION VERSION_GREATER_EQUAL 6) + if(INSTALLED_QT_VERSION VERSION_GREATER_EQUAL 6) # Qt6 provides the plugins as individual packages that need to be found. find_package(Qt${INSTALLED_QT_VERSION}${_qt_plugin} QUIET PATHS ${Qt${INSTALLED_QT_VERSION}${_qt_comp}_DIR}) @@ -117,7 +117,7 @@ if(CMake_INSTALL_DEPENDENCIES AND (APPLE OR WIN32)) endforeach() endmacro() if(APPLE) - if (INSTALLED_QT_VERSION VERSION_EQUAL 5) + if(INSTALLED_QT_VERSION VERSION_EQUAL 5) install_qt_plugin("Qt5::QCocoaIntegrationPlugin" QT_PLUGINS) if(TARGET Qt5::QMacStylePlugin) install_qt_plugin("Qt5::QMacStylePlugin" QT_PLUGINS) @@ -132,7 +132,7 @@ if(CMake_INSTALL_DEPENDENCIES AND (APPLE OR WIN32)) DESTINATION "${CMAKE_INSTALL_PREFIX}/Resources" ${COMPONENT}) elseif(WIN32 AND NOT CMake_QT_STATIC_QWindowsIntegrationPlugin_LIBRARIES) - if (INSTALLED_QT_VERSION VERSION_EQUAL 5) + if(INSTALLED_QT_VERSION VERSION_EQUAL 5) install_qt_plugin("Qt5::QWindowsIntegrationPlugin" QT_PLUGINS) else() # FIXME: Minimize plugins for Qt6. @@ -204,7 +204,7 @@ set(MOC_SRCS ) set(QRC_SRCS CMakeSetup.qrc) -if (INSTALLED_QT_VERSION VERSION_LESS 6) +if(INSTALLED_QT_VERSION VERSION_LESS 6) qt5_wrap_ui(UI_BUILT_SRCS ${UI_SRCS}) qt5_wrap_cpp(MOC_BUILT_SRCS ${MOC_SRCS}) qt5_add_resources(QRC_BUILT_SRCS ${QRC_SRCS}) @@ -215,15 +215,15 @@ else() endif() add_library(CMakeGUIQRCLib OBJECT ${QRC_BUILT_SRCS}) -if (FALSE) # CMake's bootstrap binary does not support automoc +if(FALSE) # CMake's bootstrap binary does not support automoc set(CMAKE_AUTOMOC 1) set(CMAKE_AUTORCC 1) set(CMAKE_AUTOUIC 1) -else () +else() list(APPEND SRCS ${UI_BUILT_SRCS} ${MOC_BUILT_SRCS}) -endif () +endif() if(USE_LGPL) install(FILES ${CMake_SOURCE_DIR}/Licenses/LGPLv${USE_LGPL}.txt diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 24a7c88..d9b3c03 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -89,7 +89,7 @@ if(BUILD_TESTING) endif() endif() - set(MAKE_IS_GNU ) + set(MAKE_IS_GNU) if(CMAKE_MAKE_PROGRAM MATCHES make) execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} no_such_target --version RESULT_VARIABLE res OUTPUT_VARIABLE out ERROR_VARIABLE out) @@ -101,7 +101,7 @@ if(BUILD_TESTING) endif() # some old versions of make simply cannot handle spaces in paths - if (MAKE_IS_GNU OR + if(MAKE_IS_GNU OR CMAKE_MAKE_PROGRAM MATCHES "nmake|gmake|wmake" OR CMAKE_GENERATOR MATCHES "Visual Studio|Xcode|Borland|Ninja") set(MAKE_SUPPORTS_SPACES 1) @@ -181,7 +181,7 @@ if(BUILD_TESTING) ERROR_VARIABLE my_err) string(REGEX REPLACE "HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Wow6432Node\\\\Microsoft\\\\Windows CE Tools\\\\SDKs\\\\" ";" sdk_list "${sdk_reg}") list(LENGTH sdk_list sdk_list_len) - if (${sdk_list_len} GREATER 1) + if(${sdk_list_len} GREATER 1) list(GET sdk_list 1 _sdk) # The first entry is always empty due to the regex replace above string(STRIP ${_sdk} _sdk) # Make sure there is no newline in the SDK name endif() @@ -287,12 +287,12 @@ if(BUILD_TESTING) "Should the long tests be run (such as Bootstrap)." ON) mark_as_advanced(CMAKE_RUN_LONG_TESTS) - if (CMAKE_RUN_LONG_TESTS) + if(CMAKE_RUN_LONG_TESTS) option(CTEST_TEST_CTEST "Should the tests that run a full sub ctest process be run?" OFF) mark_as_advanced(CTEST_TEST_CTEST) - endif () + endif() option(CTEST_TEST_CPACK "Should the tests that use '--build-target package' be run?" @@ -367,9 +367,9 @@ if(BUILD_TESTING) if(CMake_TEST_RESOURCES) ADD_TEST_MACRO(VSResource VSResource) - if (CMAKE_GENERATOR MATCHES "Ninja") + if(CMAKE_GENERATOR MATCHES "Ninja") add_test_macro(VSResourceNinjaForceRSP VSResourceNinjaForceRSP) - endif () + endif() endif() if(_isMultiConfig) set(MSManifest_CTEST_OPTIONS -C $) @@ -499,7 +499,7 @@ if(BUILD_TESTING) endif() ADD_TEST_MACRO(SourcesProperty SourcesProperty) ADD_TEST_MACRO(SourceFileProperty SourceFileProperty) - if (NOT CMAKE_GENERATOR STREQUAL "Xcode") + if(NOT CMAKE_GENERATOR STREQUAL "Xcode") ADD_TEST_MACRO(SourceFileIncludeDirProperty SourceFileIncludeDirProperty) endif() if(CMAKE_CXX_COMPILER_ID STREQUAL "LCC" OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" @@ -646,11 +646,11 @@ if(BUILD_TESTING) ADD_TEST_MACRO(Module.WriteCompilerDetectionHeader WriteCompilerDetectionHeader) - if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "LCC") + if(APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "LCC") include(CheckCXXCompilerFlag) check_cxx_compiler_flag(-fPIE run_pic_test) else() - if (CMAKE_CXX_COMPILER_ID MATCHES "PGI" + if(CMAKE_CXX_COMPILER_ID MATCHES "PGI" OR CMAKE_CXX_COMPILER_ID MATCHES "PathScale" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") set(run_pic_test 0) @@ -659,7 +659,7 @@ if(BUILD_TESTING) endif() endif() - if (run_pic_test) + if(run_pic_test) ADD_TEST_MACRO(PositionIndependentTargets PositionIndependentTargets) endif() @@ -793,7 +793,7 @@ if(BUILD_TESTING) --build-exe-dir "${CMake_BINARY_DIR}/Tests/SubProject/foo" --test-command foo ) - set_tests_properties ( SubProject-Stage2 PROPERTIES DEPENDS SubProject) + set_tests_properties(SubProject-Stage2 PROPERTIES DEPENDS SubProject) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubProject") endif() @@ -1352,7 +1352,7 @@ if(BUILD_TESTING) --test-command complex) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ComplexOneConfig") # because of the registry write these tests depend on each other - set_tests_properties ( complex PROPERTIES DEPENDS complexOneConfig) + set_tests_properties(complex PROPERTIES DEPENDS complexOneConfig) add_test(Environment ${CMAKE_CTEST_COMMAND} --build-and-test @@ -1540,7 +1540,7 @@ if(BUILD_TESTING) # CMake_TEST_FindMatlab_MCR_ROOT_DIR: indicates an optional root directory for the MCR, required on Linux if(CMake_TEST_FindMatlab OR CMake_TEST_FindMatlab_ROOT_DIR OR CMake_TEST_FindMatlab_MCR OR CMake_TEST_FindMatlab_MCR_ROOT_DIR) - set(FindMatlab_additional_test_options ) + set(FindMatlab_additional_test_options) if(CMake_TEST_FindMatlab_MCR OR CMake_TEST_FindMatlab_MCR_ROOT_DIR) set(FindMatlab_additional_test_options -DIS_MCR=TRUE) endif() @@ -1673,7 +1673,8 @@ if(BUILD_TESTING) RUN_SERIAL 1 TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT} WORKING_DIRECTORY ${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate - DEPENDS ExternalProjectUpdateSetup ) + DEPENDS ExternalProjectUpdateSetup + ) execute_process( COMMAND ${CMAKE_COMMAND} @@ -1728,7 +1729,7 @@ if(BUILD_TESTING) function(add_tutorial_test step_name use_mymath tutorial_arg pass_regex) set(tutorial_test_name Tutorial${step_name}) set(tutorial_build_dir "${CMake_BINARY_DIR}/Tests/Tutorial/${step_name}") - if (use_mymath) + if(use_mymath) set(tutorial_build_options "") else() set(tutorial_test_name ${tutorial_test_name}_MYMATH) @@ -1752,7 +1753,7 @@ if(BUILD_TESTING) if(NOT CMake_TEST_EXTERNAL_CMAKE) foreach(STP RANGE 2 12) - if (STP EQUAL 8) + if(STP EQUAL 8) set(pass_regex ".*using log and exp") else() set(pass_regex "The square root of 25 is 5") @@ -2011,11 +2012,11 @@ if(BUILD_TESTING) --test-command Exec2 ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LinkLineOrder") - set_tests_properties ( qtwrapping PROPERTIES DEPENDS wrapping) - set_tests_properties ( testdriver1 PROPERTIES DEPENDS qtwrapping) - set_tests_properties ( testdriver2 PROPERTIES DEPENDS testdriver1) - set_tests_properties ( testdriver3 PROPERTIES DEPENDS testdriver2) - set_tests_properties ( linkorder2 PROPERTIES DEPENDS linkorder1) + set_tests_properties(qtwrapping PROPERTIES DEPENDS wrapping) + set_tests_properties(testdriver1 PROPERTIES DEPENDS qtwrapping) + set_tests_properties(testdriver2 PROPERTIES DEPENDS testdriver1) + set_tests_properties(testdriver3 PROPERTIES DEPENDS testdriver2) + set_tests_properties(linkorder2 PROPERTIES DEPENDS linkorder1) # Test static linking on toolchains known to support it. if((CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "LCC") @@ -2047,9 +2048,9 @@ if(BUILD_TESTING) "${CMake_BINARY_DIR}/Tests/SubDirSpaces/testfromsubdir.obj" ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubDirSpaces") - endif () + endif() - if (WIN32) + if(WIN32) add_test(SubDir ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/SubDir" @@ -2061,7 +2062,7 @@ if(BUILD_TESTING) "${CMake_BINARY_DIR}/Tests/SubDir/ShouldBeHere" "${CMake_BINARY_DIR}/Tests/SubDir/testfromsubdir.obj" ) - else () + else() add_test(SubDir ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/SubDir" @@ -2073,7 +2074,7 @@ if(BUILD_TESTING) "${CMake_BINARY_DIR}/Tests/SubDir/ShouldBeHere" "${CMake_BINARY_DIR}/Tests/SubDir/testfromsubdir.o" ) - endif () + endif() list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubDir") if(MSVC OR (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND CMAKE_C_SIMULATE_ID STREQUAL "MSVC")) @@ -2106,7 +2107,7 @@ if(BUILD_TESTING) ADD_TEST_MACRO(ModuleDefinition example_exe) endif() - if (CMAKE_C_COMPILER_ID MATCHES "Watcom" AND WIN32) + if(CMAKE_C_COMPILER_ID MATCHES "Watcom" AND WIN32) ADD_TEST_MACRO(WatcomRuntimeLibrary) endif() @@ -2321,7 +2322,7 @@ if(BUILD_TESTING) ADD_TEST_MACRO(VSNASM VSNASM) endif() - if (CMake_TEST_GreenHillsMULTI) + if(CMake_TEST_GreenHillsMULTI) macro(add_test_GhsMulti test_name test_dir bin_sub_dir build_opts) separate_arguments(_ghs_build_opts UNIX_COMMAND ${build_opts}) separate_arguments(_ghs_toolset_extra UNIX_COMMAND ${ghs_toolset_extra}) @@ -2382,7 +2383,7 @@ if(BUILD_TESTING) set(ghs_config_name "__default__") endif() # test integrity build - if (NOT ghs_skip_integrity AND (NOT ghs_target_platform OR ghs_target_platform MATCHES "integrity")) + if(NOT ghs_skip_integrity AND (NOT ghs_target_platform OR ghs_target_platform MATCHES "integrity")) add_test_GhsMulti(integrityDDInt GhsMultiIntegrity/GhsMultiIntegrityDDInt "" "") add_test_GhsMulti(integrityMonolith GhsMultiIntegrity/GhsMultiIntegrityMonolith "" "") add_test_GhsMulti(integrityDD GhsMultiIntegrity/GhsMultiIntegrityDD "" "") @@ -2464,8 +2465,8 @@ if(BUILD_TESTING) add_test_VSAndroid(vs17 "Visual Studio 17 2022" "ARM") endif() - if (APPLE) - if (CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + if(APPLE) + if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") set(BundleTestInstallDir "${CMake_BINARY_DIR}/Tests/BundleTest/InstallDirectory") add_test(BundleTest ${CMAKE_CTEST_COMMAND} @@ -2501,8 +2502,8 @@ if(BUILD_TESTING) add_subdirectory(ObjC) add_subdirectory(ObjCXX) - endif () - endif () + endif() + endif() if(APPLE AND CTEST_TEST_CPACK) add_test(BundleGeneratorTest ${CMAKE_CTEST_COMMAND} @@ -3223,24 +3224,24 @@ if(BUILD_TESTING) --output-log "${CMake_BINARY_DIR}/Tests/CTestTestFdSetSize/testOutput.log" ) - if (CMAKE_TESTS_CDASH_SERVER) + if(CMAKE_TESTS_CDASH_SERVER) set(regex "^([^:]+)://([^/]+)(.*)$") - if ("${CMAKE_TESTS_CDASH_SERVER}" MATCHES "${regex}") + if("${CMAKE_TESTS_CDASH_SERVER}" MATCHES "${regex}") set(protocol "${CMAKE_MATCH_1}") set(server "${CMAKE_MATCH_2}") set(path "${CMAKE_MATCH_3}") - else () + else() set(protocol "http") set(server "open.cdash.org") set(path "") message("warning: CMAKE_TESTS_CDASH_SERVER does not match expected regex...") message(" ...using default url='${protocol}://${server}${path}' for CTestTest[23]") - endif () - endif () + endif() + endif() - if (CTEST_TEST_CTEST AND CMAKE_RUN_LONG_TESTS AND CMAKE_TESTS_CDASH_SERVER) + if(CTEST_TEST_CTEST AND CMAKE_RUN_LONG_TESTS AND CMAKE_TESTS_CDASH_SERVER) configure_file("${CMake_SOURCE_DIR}/Tests/CTestTest/test.cmake.in" "${CMake_BINARY_DIR}/Tests/CTestTest/test.cmake" @ONLY ESCAPE_QUOTES) add_test(CTestTest ${CMAKE_CTEST_COMMAND} @@ -3282,19 +3283,19 @@ if(BUILD_TESTING) # these tests take a long time, make sure they have it # if timeouts have not already been set get_test_property(CTestTest TIMEOUT PREVIOUS_TIMEOUT) - if ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) - set_tests_properties ( CTestTest + if("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) + set_tests_properties(CTestTest PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) - endif () + endif() if(NOT CMake_TEST_EXTERNAL_CMAKE) get_test_property(CTestTest2 TIMEOUT PREVIOUS_TIMEOUT) if("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) - set_tests_properties ( CTestTest2 + set_tests_properties(CTestTest2 PROPERTIES TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) endif() endif() - endif () + endif() if(CMake_TEST_EXTERNAL_CMAKE) set(CMAKE_SKIP_BOOTSTRAP_TEST 1) @@ -3330,10 +3331,9 @@ if(BUILD_TESTING) # provide more time for the bootstrap test get_test_property(BootstrapTest TIMEOUT PREVIOUS_TIMEOUT) - if ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) - set_tests_properties ( BootstrapTest - PROPERTIES TIMEOUT 5400) - endif () + if("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) + set_tests_properties(BootstrapTest PROPERTIES TIMEOUT 5400) + endif() endif() if(CMAKE_Fortran_COMPILER) @@ -3412,7 +3412,7 @@ if(BUILD_TESTING) ) # E2K has broken Java RVM before 3.5.2 - if (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "e2k" AND _result EQUAL 0) + if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "e2k" AND _result EQUAL 0) string(REGEX MATCH "RVM ([0-9.]+)" RVMVER "${_version}") # Consider empty match a broken version too if("${CMAKE_MATCH_1}" VERSION_LESS "3.5.2") @@ -3435,7 +3435,7 @@ if(BUILD_TESTING) math(EXPR _object_mode "${CMAKE_SIZEOF_VOID_P} * 8") if(_result EQUAL 0 AND _version MATCHES "${_object_mode}-Bit") ## next test is valid only if Java version is less than 1.10 - if ("${Java_VERSION}" VERSION_LESS 1.10) + if("${Java_VERSION}" VERSION_LESS 1.10) add_test(NAME Java.Javah COMMAND ${CMAKE_CTEST_COMMAND} -C $ --build-and-test "${CMake_SOURCE_DIR}/Tests/JavaJavah" @@ -3447,7 +3447,7 @@ if(BUILD_TESTING) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJavah") endif() ## next test is valid only if Java is, at least, version 1.8 - if (NOT "${Java_VERSION}" VERSION_LESS 1.8) + if(NOT "${Java_VERSION}" VERSION_LESS 1.8) add_test(NAME Java.NativeHeaders COMMAND ${CMAKE_CTEST_COMMAND} -C $ --build-and-test "${CMake_SOURCE_DIR}/Tests/JavaNativeHeaders" @@ -3522,18 +3522,18 @@ if(BUILD_TESTING) endif() if(CMAKE_TEST_PLPLOT_DIR) - add_test(plplot ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_PLPLOT_DIR}/../../EasyDashboardScripts/plplot.cmake ) + add_test(plplot ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_PLPLOT_DIR}/../../EasyDashboardScripts/plplot.cmake) set_tests_properties ( plplot PROPERTIES TIMEOUT 5400) endif() if(CMAKE_TEST_CHICKEN_DIR) - add_test(Chicken ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_CHICKEN_DIR}/../../EasyDashboardScripts/Chicken.cmake ) - set_tests_properties ( Chicken PROPERTIES TIMEOUT 5400) + add_test(Chicken ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_CHICKEN_DIR}/../../EasyDashboardScripts/Chicken.cmake) + set_tests_properties(Chicken PROPERTIES TIMEOUT 5400) endif() if(CMAKE_TEST_KDELIBS_ALPHA_1_DIR) - add_test(KDELibsAlpha1 ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_KDELIBS_ALPHA_1_DIR}/../../EasyDashboardScripts/kdelibs.cmake ) - set_tests_properties ( KDELibsAlpha1 PROPERTIES TIMEOUT 5400) + add_test(KDELibsAlpha1 ${CMAKE_CTEST_COMMAND} -V -S ${CMAKE_TEST_KDELIBS_ALPHA_1_DIR}/../../EasyDashboardScripts/kdelibs.cmake) + set_tests_properties(KDELibsAlpha1 PROPERTIES TIMEOUT 5400) endif() # Define a set of "contract" tests, each activated by a cache entry -- cgit v0.12 From a67c9f975686d4036a31597d535982c31df97ebe Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 02:26:58 +0400 Subject: cmake.version.manifest: Replace tabs with spaces --- Source/cmake.version.manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmake.version.manifest b/Source/cmake.version.manifest index e7010c9..79e3d19 100644 --- a/Source/cmake.version.manifest +++ b/Source/cmake.version.manifest @@ -1,6 +1,6 @@ + xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" > -- cgit v0.12 From 0aed435b351577681a7cbbd8c542fbe998d1717d Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 04:48:36 +0400 Subject: Build: Simplify `configure_file()` calls --- CMakeLists.txt | 29 ++++++++-------------------- Source/CMakeLists.txt | 28 ++++++++------------------- Source/CursesDialog/form/CMakeLists.txt | 2 +- Source/QtDialog/CMakeLists.txt | 3 +-- Tests/CMakeLib/CMakeLists.txt | 6 ++---- Tests/CMakeLib/PseudoMemcheck/CMakeLists.txt | 2 +- 6 files changed, 21 insertions(+), 49 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 00e0052..54ff7e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,9 +114,7 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE) endif() # Inform STL library header wrappers whether to use system versions. -configure_file(${CMake_SOURCE_DIR}/Utilities/std/cmSTL.hxx.in - ${CMake_BINARY_DIR}/Utilities/cmSTL.hxx - @ONLY) +configure_file(Utilities/std/cmSTL.hxx.in Utilities/cmSTL.hxx @ONLY) # set the internal encoding of CMake to UTF-8 set(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_UTF8) @@ -222,9 +220,7 @@ macro(CMAKE_HANDLE_SYSTEM_LIBRARIES) endforeach() # Inform utility library header wrappers whether to use system versions. - configure_file(${CMake_SOURCE_DIR}/Utilities/cmThirdParty.h.in - ${CMake_BINARY_DIR}/Utilities/cmThirdParty.h - @ONLY) + configure_file(Utilities/cmThirdParty.h.in Utilities/cmThirdParty.h @ONLY) endmacro() @@ -262,18 +258,12 @@ macro(CMAKE_SETUP_TESTING) endif() # configure some files for testing - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Templates/CTestScript.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/CTestScript.cmake" - @ONLY) - configure_file(${CMake_SOURCE_DIR}/Tests/.NoDartCoverage - ${CMake_BINARY_DIR}/Tests/.NoDartCoverage) - configure_file(${CMake_SOURCE_DIR}/Tests/.NoDartCoverage - ${CMake_BINARY_DIR}/Modules/.NoDartCoverage) - configure_file(${CMake_SOURCE_DIR}/CTestCustom.cmake.in - ${CMake_BINARY_DIR}/CTestCustom.cmake @ONLY) + configure_file(Templates/CTestScript.cmake.in CTestScript.cmake @ONLY) + configure_file(Tests/.NoDartCoverage Tests/.NoDartCoverage) + configure_file(Tests/.NoDartCoverage Modules/.NoDartCoverage) + configure_file(CTestCustom.cmake.in CTestCustom.cmake @ONLY) if(BUILD_TESTING AND DART_ROOT) - configure_file(${CMake_SOURCE_DIR}/CMakeLogo.gif - ${CMake_BINARY_DIR}/Testing/HTML/TestingResults/Icons/Logo.gif COPYONLY) + configure_file(CMakeLogo.gif Testing/HTML/TestingResults/Icons/Logo.gif COPYONLY) endif() mark_as_advanced(DART_ROOT) endmacro() @@ -829,10 +819,7 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE) endif() # add the uninstall support - configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" - @ONLY) + configure_file(cmake_uninstall.cmake.in cmake_uninstall.cmake @ONLY) add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index b1a79af..82978d5 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -43,31 +43,19 @@ endif() # configure the .dox.in file if(CMake_BUILD_DEVELOPER_REFERENCE) - configure_file( - "${CMake_SOURCE_DIR}/Source/dir.dox.in" - "${CMake_BINARY_DIR}/Source/dir.dox" - @ONLY - ) + configure_file(dir.dox.in dir.dox @ONLY) endif() # configure the .h file -configure_file( - "${CMake_SOURCE_DIR}/Source/cmConfigure.cmake.h.in" - "${CMake_BINARY_DIR}/Source/cmConfigure.h" - ) -configure_file( - "${CMake_SOURCE_DIR}/Source/cmVersionConfig.h.in" - "${CMake_BINARY_DIR}/Source/cmVersionConfig.h" - ) -configure_file( - "${CMake_SOURCE_DIR}/Source/CPack/cmCPackConfigure.h.in" - "${CMake_BINARY_DIR}/Source/CPack/cmCPackConfigure.h" - ) +configure_file(cmConfigure.cmake.h.in cmConfigure.h) +configure_file(cmVersionConfig.h.in cmVersionConfig.h) +configure_file(CPack/cmCPackConfigure.h.in CPack/cmCPackConfigure.h) # Tell CMake executable in the build tree where to find the source tree. configure_file( - "${CMake_SOURCE_DIR}/Source/CMakeSourceDir.txt.in" - "${CMake_BINARY_DIR}/CMakeFiles/CMakeSourceDir.txt" @ONLY + CMakeSourceDir.txt.in + "${CMake_BINARY_DIR}/CMakeFiles/CMakeSourceDir.txt" + @ONLY ) # add the include path to find the .h @@ -1208,7 +1196,7 @@ if(WIN32) set(CMake_RCVERSION_STR ${CMake_VERSION}) # Add Windows executable version information. - configure_file("CMakeVersion.rc.in" "CMakeVersion.rc" @ONLY) + configure_file(CMakeVersion.rc.in CMakeVersion.rc @ONLY) # We use a separate object library for this to work around a limitation of # MinGW's windres tool with spaces in the path to the include directories. diff --git a/Source/CursesDialog/form/CMakeLists.txt b/Source/CursesDialog/form/CMakeLists.txt index 68d28c8..63214e3 100644 --- a/Source/CursesDialog/form/CMakeLists.txt +++ b/Source/CursesDialog/form/CMakeLists.txt @@ -11,7 +11,7 @@ elseif(CMAKE_C_COMPILER_ID STREQUAL "PathScale") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall") endif() -configure_file(cmFormConfigure.h.in "${CMAKE_CURRENT_BINARY_DIR}/cmFormConfigure.h") +configure_file(cmFormConfigure.h.in cmFormConfigure.h) add_library(cmForm fld_arg.c diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index 95962d8..a635200 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -348,5 +348,4 @@ if(CMake_INSTALL_DEPENDENCIES AND (APPLE OR WIN32)) endif() set(CMAKE_PACKAGE_QTGUI TRUE) -configure_file("${QtDialog_SOURCE_DIR}/QtDialogCPack.cmake.in" - "${QtDialog_BINARY_DIR}/QtDialogCPack.cmake" @ONLY) +configure_file(QtDialogCPack.cmake.in QtDialogCPack.cmake @ONLY) diff --git a/Tests/CMakeLib/CMakeLists.txt b/Tests/CMakeLib/CMakeLists.txt index 1d45162..612d4b4 100644 --- a/Tests/CMakeLib/CMakeLists.txt +++ b/Tests/CMakeLib/CMakeLists.txt @@ -47,12 +47,10 @@ if(WIN32) list(APPEND CMakeLib_TESTS testVisualStudioSlnParser.cxx ) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/testVisualStudioSlnParser.h.in - ${CMAKE_CURRENT_BINARY_DIR}/testVisualStudioSlnParser.h @ONLY) + configure_file(testVisualStudioSlnParser.h.in testVisualStudioSlnParser.h @ONLY) endif() -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/testXMLParser.h.in - ${CMAKE_CURRENT_BINARY_DIR}/testXMLParser.h @ONLY) +configure_file(testXMLParser.h.in testXMLParser.h @ONLY) create_test_sourcelist(CMakeLib_TEST_SRCS CMakeLibTests.cxx ${CMakeLib_TESTS}) add_executable(CMakeLibTests ${CMakeLib_TEST_SRCS}) diff --git a/Tests/CMakeLib/PseudoMemcheck/CMakeLists.txt b/Tests/CMakeLib/PseudoMemcheck/CMakeLists.txt index 3f2f891..b4bc921 100644 --- a/Tests/CMakeLib/PseudoMemcheck/CMakeLists.txt +++ b/Tests/CMakeLib/PseudoMemcheck/CMakeLists.txt @@ -1,5 +1,5 @@ foreach(_retval IN ITEMS 0 1) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/memtester.cxx.in" "${CMAKE_CURRENT_BINARY_DIR}/ret${_retval}.cxx" @ONLY) + configure_file(memtester.cxx.in ret${_retval}.cxx @ONLY) endforeach() include_directories(${CMake_SOURCE_DIR}/Source ${CMake_BINARY_DIR}/Source) -- cgit v0.12 From 4ff86046048882487d582cf463ce49b0f708223c Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 05:10:11 +0400 Subject: Build: Do not use variables for sources lists Instead use `add_library()` with unconditionally compiled sources and conditional `target_sources()` with extra sources to compile. --- Source/CMakeLists.txt | 355 ++++++++++++++++++++++------------------- Source/QtDialog/CMakeLists.txt | 31 ++-- 2 files changed, 208 insertions(+), 178 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 82978d5..579855f 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -69,20 +69,10 @@ include_directories( ${CMake_HAIKU_INCLUDE_DIRS} ) -# Check if we can build the Mach-O parser. -if(CMake_USE_MACH_PARSER) - set(MACH_SRCS cmMachO.h cmMachO.cxx) -endif() - -# Check if we can build the XCOFF parser. -if(CMake_USE_XCOFF_PARSER) - set(XCOFF_SRCS cmXCOFF.h cmXCOFF.cxx) -endif() - # -# Sources for CMakeLib -# -set(SRCS +# create a library used by the command line and the GUI +add_library( + CMakeLib # Lexers/Parsers LexerParser/cmCommandArgumentLexer.cxx LexerParser/cmCommandArgumentLexer.h @@ -358,7 +348,6 @@ set(SRCS cmRulePlaceholderExpander.h cmLocalUnixMakefileGenerator3.cxx cmLocale.h - ${MACH_SRCS} cmMakefile.cxx cmMakefile.h cmMakefileTargetGenerator.cxx @@ -458,7 +447,6 @@ set(SRCS cmWorkerPool.h cmWorkingDirectory.cxx cmWorkingDirectory.h - ${XCOFF_SRCS} cmXMLParser.cxx cmXMLParser.h cmXMLSafe.cxx @@ -718,6 +706,23 @@ set(SRCS cmWhileCommand.h cmWriteFileCommand.cxx cmWriteFileCommand.h + # Ninja support + cmScanDepFormat.cxx + cmGlobalNinjaGenerator.cxx + cmGlobalNinjaGenerator.h + cmNinjaTypes.h + cmLocalNinjaGenerator.cxx + cmLocalNinjaGenerator.h + cmNinjaTargetGenerator.cxx + cmNinjaTargetGenerator.h + cmNinjaNormalTargetGenerator.cxx + cmNinjaNormalTargetGenerator.h + cmNinjaUtilityTargetGenerator.cxx + cmNinjaUtilityTargetGenerator.h + cmNinjaLinkLineComputer.cxx + cmNinjaLinkLineComputer.h + cmNinjaLinkLineDeviceComputer.cxx + cmNinjaLinkLineDeviceComputer.h cm_get_date.h cm_get_date.c @@ -732,80 +737,121 @@ set(SRCS bindexplib.cxx ) +target_link_libraries( + CMakeLib + PUBLIC + cmsys + ${CMAKE_STD_LIBRARY} + ${CMAKE_EXPAT_LIBRARIES} ${CMAKE_ZLIB_LIBRARIES} + ${CMAKE_TAR_LIBRARIES} + ${CMAKE_CURL_LIBRARIES} + ${CMAKE_JSONCPP_LIBRARIES} + ${CMAKE_LIBUV_LIBRARIES} + ${CMAKE_LIBRHASH_LIBRARIES} + ${CMake_KWIML_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} + ) + SET_PROPERTY(SOURCE cmProcessOutput.cxx cmWindowsRegistry.cxx APPEND PROPERTY COMPILE_DEFINITIONS KWSYS_ENCODING_DEFAULT_CODEPAGE=${KWSYS_ENCODING_DEFAULT_CODEPAGE}) +# Check if we can build the Mach-O parser. +if(CMake_USE_MACH_PARSER) + target_sources( + CMakeLib + PUBLIC + cmMachO.h + cmMachO.cxx + ) +endif() + +# Check if we can build the XCOFF parser. +if(CMake_USE_XCOFF_PARSER) + target_sources( + CMakeLib + PUBLIC + cmXCOFF.h + cmXCOFF.cxx + ) +endif() + # Xcode only works on Apple if(APPLE) - set(SRCS ${SRCS} - cmXCodeObject.cxx - cmXCode21Object.cxx - cmXCodeScheme.cxx - cmGlobalXCodeGenerator.cxx - cmGlobalXCodeGenerator.h - cmLocalXCodeGenerator.cxx - cmLocalXCodeGenerator.h) + target_sources( + CMakeLib + PUBLIC + cmXCodeObject.cxx + cmXCode21Object.cxx + cmXCodeScheme.cxx + cmGlobalXCodeGenerator.cxx + cmGlobalXCodeGenerator.h + cmLocalXCodeGenerator.cxx + cmLocalXCodeGenerator.h + ) endif() - if(WIN32) - set(SRCS ${SRCS} - cmCallVisualStudioMacro.cxx - cmCallVisualStudioMacro.h + target_sources( + CMakeLib + PUBLIC + cmCallVisualStudioMacro.cxx + cmCallVisualStudioMacro.h ) if(NOT UNIX) - set(SRCS ${SRCS} - cmGlobalBorlandMakefileGenerator.cxx - cmGlobalBorlandMakefileGenerator.h - cmGlobalMSYSMakefileGenerator.cxx - cmGlobalMinGWMakefileGenerator.cxx - cmGlobalNMakeMakefileGenerator.cxx - cmGlobalNMakeMakefileGenerator.h - cmGlobalJOMMakefileGenerator.cxx - cmGlobalJOMMakefileGenerator.h - cmGlobalVisualStudio71Generator.cxx - cmGlobalVisualStudio71Generator.h - cmGlobalVisualStudio7Generator.cxx - cmGlobalVisualStudio7Generator.h - cmGlobalVisualStudio8Generator.cxx - cmGlobalVisualStudio8Generator.h - cmGlobalVisualStudio9Generator.cxx - cmGlobalVisualStudio9Generator.h - cmVisualStudioGeneratorOptions.h - cmVisualStudioGeneratorOptions.cxx - cmVsProjectType.h - cmVisualStudio10TargetGenerator.h - cmVisualStudio10TargetGenerator.cxx - cmLocalVisualStudio10Generator.cxx - cmLocalVisualStudio10Generator.h - cmGlobalVisualStudio10Generator.h - cmGlobalVisualStudio10Generator.cxx - cmGlobalVisualStudio11Generator.h - cmGlobalVisualStudio11Generator.cxx - cmGlobalVisualStudio12Generator.h - cmGlobalVisualStudio12Generator.cxx - cmGlobalVisualStudio14Generator.h - cmGlobalVisualStudio14Generator.cxx - cmGlobalVisualStudioGenerator.cxx - cmGlobalVisualStudioGenerator.h - cmGlobalVisualStudioVersionedGenerator.h - cmGlobalVisualStudioVersionedGenerator.cxx - cmIDEFlagTable.h - cmIDEOptions.cxx - cmIDEOptions.h - cmLocalVisualStudio7Generator.cxx - cmLocalVisualStudio7Generator.h - cmLocalVisualStudioGenerator.cxx - cmLocalVisualStudioGenerator.h - cmVisualStudioSlnData.h - cmVisualStudioSlnData.cxx - cmVisualStudioSlnParser.h - cmVisualStudioSlnParser.cxx - cmVisualStudioWCEPlatformParser.h - cmVisualStudioWCEPlatformParser.cxx - cmVSSetupHelper.cxx - cmVSSetupHelper.h + target_sources( + CMakeLib + PUBLIC + cmGlobalBorlandMakefileGenerator.cxx + cmGlobalBorlandMakefileGenerator.h + cmGlobalMSYSMakefileGenerator.cxx + cmGlobalMinGWMakefileGenerator.cxx + cmGlobalNMakeMakefileGenerator.cxx + cmGlobalNMakeMakefileGenerator.h + cmGlobalJOMMakefileGenerator.cxx + cmGlobalJOMMakefileGenerator.h + cmGlobalVisualStudio71Generator.cxx + cmGlobalVisualStudio71Generator.h + cmGlobalVisualStudio7Generator.cxx + cmGlobalVisualStudio7Generator.h + cmGlobalVisualStudio8Generator.cxx + cmGlobalVisualStudio8Generator.h + cmGlobalVisualStudio9Generator.cxx + cmGlobalVisualStudio9Generator.h + cmVisualStudioGeneratorOptions.h + cmVisualStudioGeneratorOptions.cxx + cmVsProjectType.h + cmVisualStudio10TargetGenerator.h + cmVisualStudio10TargetGenerator.cxx + cmLocalVisualStudio10Generator.cxx + cmLocalVisualStudio10Generator.h + cmGlobalVisualStudio10Generator.h + cmGlobalVisualStudio10Generator.cxx + cmGlobalVisualStudio11Generator.h + cmGlobalVisualStudio11Generator.cxx + cmGlobalVisualStudio12Generator.h + cmGlobalVisualStudio12Generator.cxx + cmGlobalVisualStudio14Generator.h + cmGlobalVisualStudio14Generator.cxx + cmGlobalVisualStudioGenerator.cxx + cmGlobalVisualStudioGenerator.h + cmGlobalVisualStudioVersionedGenerator.h + cmGlobalVisualStudioVersionedGenerator.cxx + cmIDEFlagTable.h + cmIDEOptions.cxx + cmIDEOptions.h + cmLocalVisualStudio7Generator.cxx + cmLocalVisualStudio7Generator.h + cmLocalVisualStudioGenerator.cxx + cmLocalVisualStudioGenerator.h + cmVisualStudioSlnData.h + cmVisualStudioSlnData.cxx + cmVisualStudioSlnParser.h + cmVisualStudioSlnParser.cxx + cmVisualStudioWCEPlatformParser.h + cmVisualStudioWCEPlatformParser.cxx + cmVSSetupHelper.cxx + cmVSSetupHelper.h ) # Add a manifest file to executables on Windows to allow for @@ -817,16 +863,20 @@ endif() # Watcom support if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin") set_property(SOURCE cmake.cxx APPEND PROPERTY COMPILE_DEFINITIONS CMAKE_USE_WMAKE) - list(APPEND SRCS - cmGlobalWatcomWMakeGenerator.cxx - cmGlobalWatcomWMakeGenerator.h + target_sources( + CMakeLib + PUBLIC + cmGlobalWatcomWMakeGenerator.cxx + cmGlobalWatcomWMakeGenerator.h ) endif() # GHS support # Works only for windows and linux if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Linux") - set(SRCS ${SRCS} + target_sources( + CMakeLib + PUBLIC cmGlobalGhsMultiGenerator.cxx cmGlobalGhsMultiGenerator.h cmLocalGhsMultiGenerator.cxx @@ -838,27 +888,6 @@ if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Linux") ) endif() - -# Ninja support -set(SRCS ${SRCS} - cmScanDepFormat.cxx - cmGlobalNinjaGenerator.cxx - cmGlobalNinjaGenerator.h - cmNinjaTypes.h - cmLocalNinjaGenerator.cxx - cmLocalNinjaGenerator.h - cmNinjaTargetGenerator.cxx - cmNinjaTargetGenerator.h - cmNinjaNormalTargetGenerator.cxx - cmNinjaNormalTargetGenerator.h - cmNinjaUtilityTargetGenerator.cxx - cmNinjaUtilityTargetGenerator.h - cmNinjaLinkLineComputer.cxx - cmNinjaLinkLineComputer.h - cmNinjaLinkLineDeviceComputer.cxx - cmNinjaLinkLineDeviceComputer.h - ) - # Temporary variable for tools targets set(_tools) @@ -885,20 +914,6 @@ foreach(check IN ITEMS STAT_HAS_ST_MTIM STAT_HAS_ST_MTIMESPEC) COMPILE_DEFINITIONS CMake_${check}=${CMake_${check}}) endforeach() -# create a library used by the command line and the GUI -add_library(CMakeLib ${SRCS}) -target_link_libraries(CMakeLib cmsys - ${CMAKE_STD_LIBRARY} - ${CMAKE_EXPAT_LIBRARIES} ${CMAKE_ZLIB_LIBRARIES} - ${CMAKE_TAR_LIBRARIES} - ${CMAKE_CURL_LIBRARIES} - ${CMAKE_JSONCPP_LIBRARIES} - ${CMAKE_LIBUV_LIBRARIES} - ${CMAKE_LIBRHASH_LIBRARIES} - ${CMake_KWIML_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} - ) - if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR MATCHES "sparc") # the atomic instructions are implemented using libatomic on some platforms, # so linking to that may be required @@ -929,10 +944,13 @@ include_directories( "${CMake_SOURCE_DIR}/Source/CTest" ${CMAKE_CURL_INCLUDES} ) + # -# Sources for CTestLib +# Build CTestLib # -set(CTEST_SRCS cmCTest.cxx +add_library( + CTestLib + cmCTest.cxx CTest/cmProcess.cxx CTest/cmCTestBinPacker.cxx CTest/cmCTestBuildAndTestHandler.cxx @@ -999,9 +1017,6 @@ set(CTEST_SRCS cmCTest.cxx LexerParser/cmCTestResourceGroupsLexer.h LexerParser/cmCTestResourceGroupsLexer.in.l ) - -# Build CTestLib -add_library(CTestLib ${CTEST_SRCS}) target_link_libraries(CTestLib CMakeLib ${CMAKE_CURL_LIBRARIES}) # @@ -1010,10 +1025,10 @@ target_link_libraries(CTestLib CMakeLib ${CMAKE_CURL_LIBRARIES}) include_directories( "${CMake_SOURCE_DIR}/Source/CPack" ) -# -# Sources for CPack -# -set(CPACK_SRCS + +# Build CPackLib +add_library( + CPackLib CPack/cmCPackArchiveGenerator.cxx CPack/cmCPackComponentGroup.cxx CPack/cmCPackDebGenerator.cxx @@ -1024,9 +1039,7 @@ set(CPACK_SRCS CPack/cmCPackNSISGenerator.cxx CPack/cmCPackNuGetGenerator.cxx CPack/cmCPackSTGZGenerator.cxx - ) -# CPack IFW generator -set(CPACK_SRCS ${CPACK_SRCS} + # CPack IFW generator CPack/IFW/cmCPackIFWCommon.cxx CPack/IFW/cmCPackIFWCommon.h CPack/IFW/cmCPackIFWGenerator.cxx @@ -1038,19 +1051,24 @@ set(CPACK_SRCS ${CPACK_SRCS} CPack/IFW/cmCPackIFWRepository.cxx CPack/IFW/cmCPackIFWRepository.h ) +target_link_libraries(CPackLib CMakeLib) if(CYGWIN) - set(CPACK_SRCS ${CPACK_SRCS} - CPack/cmCPackCygwinBinaryGenerator.cxx - CPack/cmCPackCygwinSourceGenerator.cxx + target_sources( + CPackLib + PUBLIC + CPack/cmCPackCygwinBinaryGenerator.cxx + CPack/cmCPackCygwinSourceGenerator.cxx ) endif() option(CPACK_ENABLE_FREEBSD_PKG "Add FreeBSD pkg(8) generator to CPack." OFF) if(UNIX) - set(CPACK_SRCS ${CPACK_SRCS} - CPack/cmCPackRPMGenerator.cxx + target_sources( + CPackLib + PUBLIC + CPack/cmCPackRPMGenerator.cxx ) # Optionally, try to use pkg(8) @@ -1066,8 +1084,10 @@ if(UNIX) pkg DOC "FreeBSD pkg(8) library") if(FREEBSD_PKG_LIBRARIES) - set(CPACK_SRCS ${CPACK_SRCS} - CPack/cmCPackFreeBSDGenerator.cxx + target_sources( + CPackLib + PUBLIC + CPack/cmCPackFreeBSDGenerator.cxx ) endif() endif() @@ -1085,44 +1105,45 @@ if(CYGWIN) find_package(LibUUID) endif() if(WIN32 OR (CYGWIN AND LibUUID_FOUND)) - set(CPACK_SRCS ${CPACK_SRCS} - CPack/WiX/cmCMakeToWixPath.cxx - CPack/WiX/cmCMakeToWixPath.h - CPack/WiX/cmCPackWIXGenerator.cxx - CPack/WiX/cmCPackWIXGenerator.h - CPack/WiX/cmWIXAccessControlList.cxx - CPack/WiX/cmWIXAccessControlList.h - CPack/WiX/cmWIXDirectoriesSourceWriter.cxx - CPack/WiX/cmWIXDirectoriesSourceWriter.h - CPack/WiX/cmWIXFeaturesSourceWriter.cxx - CPack/WiX/cmWIXFeaturesSourceWriter.h - CPack/WiX/cmWIXFilesSourceWriter.cxx - CPack/WiX/cmWIXFilesSourceWriter.h - CPack/WiX/cmWIXPatch.cxx - CPack/WiX/cmWIXPatch.h - CPack/WiX/cmWIXPatchParser.cxx - CPack/WiX/cmWIXPatchParser.h - CPack/WiX/cmWIXRichTextFormatWriter.cxx - CPack/WiX/cmWIXRichTextFormatWriter.h - CPack/WiX/cmWIXShortcut.cxx - CPack/WiX/cmWIXShortcut.h - CPack/WiX/cmWIXSourceWriter.cxx - CPack/WiX/cmWIXSourceWriter.h + target_sources( + CPackLib + PUBLIC + CPack/WiX/cmCMakeToWixPath.cxx + CPack/WiX/cmCMakeToWixPath.h + CPack/WiX/cmCPackWIXGenerator.cxx + CPack/WiX/cmCPackWIXGenerator.h + CPack/WiX/cmWIXAccessControlList.cxx + CPack/WiX/cmWIXAccessControlList.h + CPack/WiX/cmWIXDirectoriesSourceWriter.cxx + CPack/WiX/cmWIXDirectoriesSourceWriter.h + CPack/WiX/cmWIXFeaturesSourceWriter.cxx + CPack/WiX/cmWIXFeaturesSourceWriter.h + CPack/WiX/cmWIXFilesSourceWriter.cxx + CPack/WiX/cmWIXFilesSourceWriter.h + CPack/WiX/cmWIXPatch.cxx + CPack/WiX/cmWIXPatch.h + CPack/WiX/cmWIXPatchParser.cxx + CPack/WiX/cmWIXPatchParser.h + CPack/WiX/cmWIXRichTextFormatWriter.cxx + CPack/WiX/cmWIXRichTextFormatWriter.h + CPack/WiX/cmWIXShortcut.cxx + CPack/WiX/cmWIXShortcut.h + CPack/WiX/cmWIXSourceWriter.cxx + CPack/WiX/cmWIXSourceWriter.h ) endif() if(APPLE) - set(CPACK_SRCS ${CPACK_SRCS} - CPack/cmCPackBundleGenerator.cxx - CPack/cmCPackDragNDropGenerator.cxx - CPack/cmCPackPKGGenerator.cxx - CPack/cmCPackProductBuildGenerator.cxx + target_sources( + CPackLib + PUBLIC + CPack/cmCPackBundleGenerator.cxx + CPack/cmCPackDragNDropGenerator.cxx + CPack/cmCPackPKGGenerator.cxx + CPack/cmCPackProductBuildGenerator.cxx ) endif() -# Build CPackLib -add_library(CPackLib ${CPACK_SRCS}) -target_link_libraries(CPackLib CMakeLib) if(APPLE) # Some compilers produce errors in the CoreServices framework headers. # Ideally such errors should be fixed by either the compiler vendor diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index a635200..4f56919 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -152,7 +152,10 @@ if(APPLE) get_filename_component(Qt_BIN_DIR "${Qt_BIN_DIR}" PATH) endif() -set(SRCS +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +add_library( + CMakeGUILib STATIC AddCacheEntry.cxx AddCacheEntry.h CMakeSetupDialog.cxx @@ -179,6 +182,16 @@ set(SRCS WarningMessagesDialog.cxx WarningMessagesDialog.h ) +# CMake_QT_EXTRA_LIBRARIES have to come before the main libraries on the link line +target_link_libraries( + CMakeGUILib + PUBLIC + CMakeLib + ${CMake_QT_EXTRA_LIBRARIES} + Qt${INSTALLED_QT_VERSION}::Core + Qt${INSTALLED_QT_VERSION}::Widgets + ) + set(UI_SRCS CMakeSetupDialog.ui Compilers.ui @@ -220,9 +233,12 @@ if(FALSE) # CMake's bootstrap binary does not support automoc set(CMAKE_AUTORCC 1) set(CMAKE_AUTOUIC 1) else() - list(APPEND SRCS - ${UI_BUILT_SRCS} - ${MOC_BUILT_SRCS}) + target_sources( + CMakeGUILib + PUBLIC + ${UI_BUILT_SRCS} + ${MOC_BUILT_SRCS} + ) endif() if(USE_LGPL) @@ -233,13 +249,6 @@ if(USE_LGPL) PROPERTY COMPILE_DEFINITIONS USE_LGPL="${USE_LGPL}") endif() -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -add_library(CMakeGUILib STATIC ${SRCS}) -# CMake_QT_EXTRA_LIBRARIES have to come before the main libraries on the link line -target_link_libraries(CMakeGUILib PUBLIC CMakeLib ${CMake_QT_EXTRA_LIBRARIES} - Qt${INSTALLED_QT_VERSION}::Core Qt${INSTALLED_QT_VERSION}::Widgets) - add_library(CMakeGUIMainLib STATIC CMakeSetup.cxx) target_link_libraries(CMakeGUIMainLib PUBLIC CMakeGUILib) -- cgit v0.12 From d6b708482ff88ff5a15f28b2c0e17ccf09c812b0 Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 05:24:39 +0400 Subject: =?UTF-8?q?CMakeVersion.cmake:=20`set(VAR=20"${VAR}=E2=80=A6")`=20?= =?UTF-8?q?=E2=86=92=20`string(APPEND=20VAR=20"=E2=80=A6")`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/CMakeVersion.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 81d2cb0..1b9ae10 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -9,7 +9,7 @@ set(CMake_VERSION_IS_DIRTY 0) set(CMake_VERSION "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}") if(DEFINED CMake_VERSION_RC) - set(CMake_VERSION "${CMake_VERSION}-rc${CMake_VERSION_RC}") + string(APPEND CMake_VERSION "-rc${CMake_VERSION_RC}") endif() # Releases define a small patch level. @@ -53,7 +53,7 @@ if(NOT CMake_VERSION_NO_GIT) # If this is not the exact commit of a release, add dev info. if(NOT "${git_subject}" MATCHES "^[Cc][Mm]ake ${CMake_VERSION}$") - set(CMake_VERSION "${CMake_VERSION}-g${git_hash}") + string(APPEND CMake_VERSION "-g${git_hash}") endif() # If this is a work tree, check whether it is dirty. @@ -68,7 +68,7 @@ if(NOT CMake_VERSION_NO_GIT) # No commit information. if(NOT CMake_VERSION_IS_RELEASE) # Generic development version. - set(CMake_VERSION "${CMake_VERSION}-git") + string(APPEND CMake_VERSION "-git") endif() endif() endif() @@ -80,5 +80,5 @@ else() set(CMake_VERSION_SUFFIX "") endif() if(CMake_VERSION_IS_DIRTY) - set(CMake_VERSION ${CMake_VERSION}-dirty) + string(APPEND CMake_VERSION "-dirty") endif() -- cgit v0.12 From d5336ed71439ef09cfc8b0b519aafee6c9076466 Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 05:49:38 +0400 Subject: =?UTF-8?q?Build:=20`include=5Fdirectories()`=20=E2=86=92=20`targe?= =?UTF-8?q?t=5Finclude=5Fdirectories()`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/CMakeLists.txt | 58 +++++++++++++++++++++------------------------------ 1 file changed, 24 insertions(+), 34 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 579855f..821f618 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -58,17 +58,6 @@ configure_file( @ONLY ) -# add the include path to find the .h -include_directories( - "${CMake_BINARY_DIR}/Source" - "${CMake_SOURCE_DIR}/Source" - "${CMake_SOURCE_DIR}/Source/LexerParser" - ${CMAKE_ZLIB_INCLUDES} - ${CMAKE_EXPAT_INCLUDES} - ${CMAKE_TAR_INCLUDES} - ${CMake_HAIKU_INCLUDE_DIRS} - ) - # # create a library used by the command line and the GUI add_library( @@ -736,7 +725,18 @@ add_library( bindexplib.cxx ) - +target_include_directories( + CMakeLib + PUBLIC + # add the include path to find the .h + "${CMake_BINARY_DIR}/Source" + "${CMake_SOURCE_DIR}/Source" + "${CMake_SOURCE_DIR}/Source/LexerParser" + ${CMAKE_ZLIB_INCLUDES} + ${CMAKE_EXPAT_INCLUDES} + ${CMAKE_TAR_INCLUDES} + ${CMake_HAIKU_INCLUDE_DIRS} + ) target_link_libraries( CMakeLib PUBLIC @@ -938,14 +938,6 @@ endif() target_compile_definitions(CMakeLib PUBLIC ${CLANG_TIDY_DEFINITIONS}) # -# CTestLib -# -include_directories( - "${CMake_SOURCE_DIR}/Source/CTest" - ${CMAKE_CURL_INCLUDES} - ) - -# # Build CTestLib # add_library( @@ -1017,16 +1009,17 @@ add_library( LexerParser/cmCTestResourceGroupsLexer.h LexerParser/cmCTestResourceGroupsLexer.in.l ) +target_include_directories( + CTestLib + PUBLIC + "${CMake_SOURCE_DIR}/Source/CTest" + ${CMAKE_CURL_INCLUDES} + ) target_link_libraries(CTestLib CMakeLib ${CMAKE_CURL_LIBRARIES}) # -# CPack -# -include_directories( - "${CMake_SOURCE_DIR}/Source/CPack" - ) - # Build CPackLib +# add_library( CPackLib CPack/cmCPackArchiveGenerator.cxx @@ -1051,6 +1044,7 @@ add_library( CPack/IFW/cmCPackIFWRepository.cxx CPack/IFW/cmCPackIFWRepository.h ) +target_include_directories(CPackLib PUBLIC "${CMake_SOURCE_DIR}/Source/CPack") target_link_libraries(CPackLib CMakeLib) if(CYGWIN) @@ -1084,11 +1078,7 @@ if(UNIX) pkg DOC "FreeBSD pkg(8) library") if(FREEBSD_PKG_LIBRARIES) - target_sources( - CPackLib - PUBLIC - CPack/cmCPackFreeBSDGenerator.cxx - ) + target_sources(CPackLib PUBLIC CPack/cmCPackFreeBSDGenerator.cxx) endif() endif() @@ -1161,14 +1151,14 @@ if(APPLE) endif() endif() if(CYGWIN AND LibUUID_FOUND) + target_include_directories(CPackLib PUBLIC ${LibUUID_INCLUDE_DIRS}) target_link_libraries(CPackLib ${LibUUID_LIBRARIES}) - include_directories(CPackLib ${LibUUID_INCLUDE_DIRS}) set_property(SOURCE CPack/cmCPackGeneratorFactory.cxx PROPERTY COMPILE_DEFINITIONS HAVE_LIBUUID) endif() if(CPACK_ENABLE_FREEBSD_PKG AND FREEBSD_PKG_INCLUDE_DIRS AND FREEBSD_PKG_LIBRARIES) + target_include_directories(CPackLib PUBLIC ${FREEBSD_PKG_INCLUDE_DIRS}) target_link_libraries(CPackLib ${FREEBSD_PKG_LIBRARIES}) - include_directories(${FREEBSD_PKG_INCLUDE_DIRS}) - add_definitions(-DHAVE_FREEBSD_PKG) + target_compile_definitions(CPackLib PUBLIC HAVE_FREEBSD_PKG) endif() # Build CMake executable -- cgit v0.12 From 9a24c648ebdc50495bf113a34373d0372bda125b Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 05:59:04 +0400 Subject: Build: Fix `target_link_libraries` to use link interface keywords --- Source/CMakeLists.txt | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 821f618..c182f2e 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -895,7 +895,7 @@ if(WIN32 AND NOT CYGWIN) set_source_files_properties(cmcldeps.cxx PROPERTIES COMPILE_DEFINITIONS _WIN32_WINNT=0x0501) add_executable(cmcldeps cmcldeps.cxx ${MANIFEST_FILE}) list(APPEND _tools cmcldeps) - target_link_libraries(cmcldeps CMakeLib) + target_link_libraries(cmcldeps PRIVATE CMakeLib) endif() foreach(v IN ITEMS CURL_CA_BUNDLE CURL_CA_PATH) @@ -919,20 +919,20 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR MATCHES "sparc" # so linking to that may be required check_library_exists(atomic __atomic_fetch_add_4 "" LIBATOMIC_NEEDED) if(LIBATOMIC_NEEDED) - target_link_libraries(CMakeLib atomic) + target_link_libraries(CMakeLib PUBLIC atomic) endif() endif() # On Apple we need CoreFoundation and CoreServices if(APPLE) - target_link_libraries(CMakeLib "-framework CoreFoundation") - target_link_libraries(CMakeLib "-framework CoreServices") + target_link_libraries(CMakeLib PUBLIC "-framework CoreFoundation") + target_link_libraries(CMakeLib PUBLIC "-framework CoreServices") endif() if(WIN32 AND NOT UNIX) # We need the rpcrt4 library on Windows. # We need the crypt32 library on Windows for crypto/cert APIs. - target_link_libraries(CMakeLib rpcrt4 crypt32) + target_link_libraries(CMakeLib PUBLIC rpcrt4 crypt32) endif() target_compile_definitions(CMakeLib PUBLIC ${CLANG_TIDY_DEFINITIONS}) @@ -1015,7 +1015,7 @@ target_include_directories( "${CMake_SOURCE_DIR}/Source/CTest" ${CMAKE_CURL_INCLUDES} ) -target_link_libraries(CTestLib CMakeLib ${CMAKE_CURL_LIBRARIES}) +target_link_libraries(CTestLib PUBLIC CMakeLib ${CMAKE_CURL_LIBRARIES}) # # Build CPackLib @@ -1045,7 +1045,7 @@ add_library( CPack/IFW/cmCPackIFWRepository.h ) target_include_directories(CPackLib PUBLIC "${CMake_SOURCE_DIR}/Source/CPack") -target_link_libraries(CPackLib CMakeLib) +target_link_libraries(CPackLib PUBLIC CMakeLib) if(CYGWIN) target_sources( @@ -1142,7 +1142,7 @@ if(APPLE) check_include_file("CoreServices/CoreServices.h" HAVE_CoreServices) if(HAVE_CoreServices) set_property(SOURCE CPack/cmCPackDragNDropGenerator.cxx PROPERTY COMPILE_DEFINITIONS HAVE_CoreServices) - target_link_libraries(CPackLib "-framework CoreServices") + target_link_libraries(CPackLib PUBLIC "-framework CoreServices") else() message(WARNING "This compiler does not appear to support\n" " #include \n" @@ -1152,29 +1152,29 @@ if(APPLE) endif() if(CYGWIN AND LibUUID_FOUND) target_include_directories(CPackLib PUBLIC ${LibUUID_INCLUDE_DIRS}) - target_link_libraries(CPackLib ${LibUUID_LIBRARIES}) + target_link_libraries(CPackLib PUBLIC ${LibUUID_LIBRARIES}) set_property(SOURCE CPack/cmCPackGeneratorFactory.cxx PROPERTY COMPILE_DEFINITIONS HAVE_LIBUUID) endif() if(CPACK_ENABLE_FREEBSD_PKG AND FREEBSD_PKG_INCLUDE_DIRS AND FREEBSD_PKG_LIBRARIES) target_include_directories(CPackLib PUBLIC ${FREEBSD_PKG_INCLUDE_DIRS}) - target_link_libraries(CPackLib ${FREEBSD_PKG_LIBRARIES}) + target_link_libraries(CPackLib PUBLIC ${FREEBSD_PKG_LIBRARIES}) target_compile_definitions(CPackLib PUBLIC HAVE_FREEBSD_PKG) endif() # Build CMake executable add_executable(cmake cmakemain.cxx cmcmd.cxx cmcmd.h ${MANIFEST_FILE}) list(APPEND _tools cmake) -target_link_libraries(cmake CMakeLib) +target_link_libraries(cmake PRIVATE CMakeLib) # Build CTest executable add_executable(ctest ctest.cxx ${MANIFEST_FILE}) list(APPEND _tools ctest) -target_link_libraries(ctest CTestLib) +target_link_libraries(ctest PRIVATE CTestLib) # Build CPack executable add_executable(cpack CPack/cpack.cxx ${MANIFEST_FILE}) list(APPEND _tools cpack) -target_link_libraries(cpack CPackLib) +target_link_libraries(cpack PRIVATE CPackLib) # Curses GUI if(BUILD_CursesDialog) -- cgit v0.12 From ae174f0dead780869fa2339bfa3a52a6117b8728 Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 06:01:17 +0400 Subject: Build: Move `CMAKE_USE_WMAKE` definition to `cmConfigure.cmake.h.in` --- Source/CMakeLists.txt | 8 ++++++-- Source/cmConfigure.cmake.h.in | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index c182f2e..1901f68 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -31,6 +31,11 @@ if(CMAKE_SYSTEM_NAME STREQUAL "AIX") set(CMake_USE_XCOFF_PARSER 1) endif() +# Watcom support +if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set(CMAKE_USE_WMAKE 1) +endif() + set(EXECUTABLE_OUTPUT_PATH ${CMake_BIN_DIR}) if(WIN32) @@ -861,8 +866,7 @@ if(WIN32) endif() # Watcom support -if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin") - set_property(SOURCE cmake.cxx APPEND PROPERTY COMPILE_DEFINITIONS CMAKE_USE_WMAKE) +if(CMAKE_USE_WMAKE) target_sources( CMakeLib PUBLIC diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in index 31d03da..ea7569f 100644 --- a/Source/cmConfigure.cmake.h.in +++ b/Source/cmConfigure.cmake.h.in @@ -22,6 +22,7 @@ #cmakedefine HAVE_UNSETENV #cmakedefine CMake_USE_MACH_PARSER #cmakedefine CMake_USE_XCOFF_PARSER +#cmakedefine CMAKE_USE_WMAKE #define CMake_DEFAULT_RECURSION_LIMIT @CMake_DEFAULT_RECURSION_LIMIT@ #define CMAKE_BIN_DIR "/@CMAKE_BIN_DIR@" #define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@" -- cgit v0.12 From 324d13b25de48943459ad39e805b6e1dd41cfe2c Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 06:05:50 +0400 Subject: Build: Move `CURL_CA_BUNDLE` and `CURL_CA_PATH` to config header --- Source/CMakeLists.txt | 6 ------ Source/cmConfigure.cmake.h.in | 3 +++ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 1901f68..aa74ed5 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -902,12 +902,6 @@ if(WIN32 AND NOT CYGWIN) target_link_libraries(cmcldeps PRIVATE CMakeLib) endif() -foreach(v IN ITEMS CURL_CA_BUNDLE CURL_CA_PATH) - if(${v}) - set_property(SOURCE cmCurl.cxx APPEND PROPERTY COMPILE_DEFINITIONS ${v}="${${v}}") - endif() -endforeach() - foreach(check IN ITEMS STAT_HAS_ST_MTIM STAT_HAS_ST_MTIMESPEC) if(KWSYS_CXX_${check}_COMPILED) # abuse KWSys check cache entry set(CMake_${check} 1) diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in index ea7569f..398b493 100644 --- a/Source/cmConfigure.cmake.h.in +++ b/Source/cmConfigure.cmake.h.in @@ -33,3 +33,6 @@ #if defined(_WIN32) && !defined(NOMINMAX) # define NOMINMAX #endif + +#cmakedefine CURL_CA_BUNDLE "@CURL_CA_BUNDLE@" +#cmakedefine CURL_CA_PATH "@CURL_CA_PATH@" -- cgit v0.12 From 1bcacccce9e60800ea826c7e79012a64fec4e687 Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 06:09:55 +0400 Subject: Build: Move `STAT_HAS_ST_MTIM`, `STAT_HAS_ST_MTIMESPEC` to config file --- Source/CMakeLists.txt | 18 ++++++++---------- Source/cmConfigure.cmake.h.in | 3 +++ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index aa74ed5..1182483 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -36,6 +36,14 @@ if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Da set(CMAKE_USE_WMAKE 1) endif() +foreach(check IN ITEMS STAT_HAS_ST_MTIM STAT_HAS_ST_MTIMESPEC) + if(KWSYS_CXX_${check}_COMPILED) # abuse KWSys check cache entry + set(CMake_${check} 1) + else() + set(CMake_${check} 0) + endif() +endforeach() + set(EXECUTABLE_OUTPUT_PATH ${CMake_BIN_DIR}) if(WIN32) @@ -902,16 +910,6 @@ if(WIN32 AND NOT CYGWIN) target_link_libraries(cmcldeps PRIVATE CMakeLib) endif() -foreach(check IN ITEMS STAT_HAS_ST_MTIM STAT_HAS_ST_MTIMESPEC) - if(KWSYS_CXX_${check}_COMPILED) # abuse KWSys check cache entry - set(CMake_${check} 1) - else() - set(CMake_${check} 0) - endif() - set_property(SOURCE cmFileTime.cxx APPEND PROPERTY - COMPILE_DEFINITIONS CMake_${check}=${CMake_${check}}) -endforeach() - if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR MATCHES "sparc") # the atomic instructions are implemented using libatomic on some platforms, # so linking to that may be required diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in index 398b493..7dc9d62 100644 --- a/Source/cmConfigure.cmake.h.in +++ b/Source/cmConfigure.cmake.h.in @@ -36,3 +36,6 @@ #cmakedefine CURL_CA_BUNDLE "@CURL_CA_BUNDLE@" #cmakedefine CURL_CA_PATH "@CURL_CA_PATH@" + +#cmakedefine01 CMake_STAT_HAS_ST_MTIM +#cmakedefine01 CMake_STAT_HAS_ST_MTIMESPEC -- cgit v0.12 From 83491ddd43fb4733940c92e9d7d7647f66f49bbe Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 06:18:13 +0400 Subject: =?UTF-8?q?Build:=20`add=5Fdefinitions()`=20=E2=86=92=20`add=5Fcom?= =?UTF-8?q?pile=5Fdefinitions()`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 2 +- CompileFlags.cmake | 4 ++-- Source/CMakeLists.txt | 4 ++-- Source/QtDialog/CMakeLists.txt | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 54ff7e2..a50e222 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -595,7 +595,7 @@ macro(CMAKE_BUILD_UTILITIES) set(EXPAT_LIBRARY ${CMAKE_EXPAT_LIBRARIES}) set(ZLIB_INCLUDE_DIR ${CMAKE_ZLIB_INCLUDES}) set(ZLIB_LIBRARY ${CMAKE_ZLIB_LIBRARIES}) - add_definitions(-DLIBARCHIVE_STATIC) + add_compile_definitions(LIBARCHIVE_STATIC) set(ENABLE_MBEDTLS OFF) set(ENABLE_NETTLE OFF) if(DEFINED CMAKE_USE_OPENSSL) diff --git a/CompileFlags.cmake b/CompileFlags.cmake index acfa29f..bf8a082 100644 --- a/CompileFlags.cmake +++ b/CompileFlags.cmake @@ -18,7 +18,7 @@ endif() # not hurt other versions, and this will work into the # future if(MSVC OR _INTEL_WINDOWS OR _CLANG_MSVC_WINDOWS) - add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE) + add_compile_definitions(_CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_DEPRECATE) else() endif() @@ -62,7 +62,7 @@ endif() # Use 64-bit off_t on 32-bit Linux if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SIZEOF_VOID_P EQUAL 4) # ensure 64bit offsets are used for filesystem accesses for 32bit compilation - add_definitions(-D_FILE_OFFSET_BITS=64) + add_compile_definitions(_FILE_OFFSET_BITS=64) endif() # Workaround for TOC Overflow on ppc64 diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 1182483..2645b7b 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -48,10 +48,10 @@ set(EXECUTABLE_OUTPUT_PATH ${CMake_BIN_DIR}) if(WIN32) # ensure Unicode friendly APIs are used on Windows - add_definitions(-DUNICODE -D_UNICODE) + add_compile_definitions(UNICODE _UNICODE) # minimize windows.h content - add_definitions(-DWIN32_LEAN_AND_MEAN) + add_compile_definitions(WIN32_LEAN_AND_MEAN) endif() # configure the .dox.in file diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index 4f56919..f3859e1 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -42,7 +42,7 @@ set(CMake_QT_EXTRA_LIBRARIES) if(WIN32) find_package(Qt${INSTALLED_QT_VERSION}WinExtras QUIET) if(Qt${INSTALLED_QT_VERSION}WinExtras_FOUND) - add_definitions(-DQT_WINEXTRAS) + add_compile_definitions(QT_WINEXTRAS) list(APPEND CMake_QT_EXTRA_LIBRARIES Qt${INSTALLED_QT_VERSION}::WinExtras) list(APPEND QT_COMPONENTS WinExtras) endif() -- cgit v0.12 From 94bc776ec2c95d847d7344f4a01e745cc9cb6651 Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 06:20:07 +0400 Subject: Style: Builtin commands in lower case --- Source/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 2645b7b..0cb2a57 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -765,7 +765,7 @@ target_link_libraries( ${CMAKE_THREAD_LIBS_INIT} ) -SET_PROPERTY(SOURCE cmProcessOutput.cxx cmWindowsRegistry.cxx APPEND PROPERTY COMPILE_DEFINITIONS +set_property(SOURCE cmProcessOutput.cxx cmWindowsRegistry.cxx APPEND PROPERTY COMPILE_DEFINITIONS KWSYS_ENCODING_DEFAULT_CODEPAGE=${KWSYS_ENCODING_DEFAULT_CODEPAGE}) # Check if we can build the Mach-O parser. -- cgit v0.12 From a392df50b3cebdaa52da9df4b0547384a9d82668 Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 06:28:51 +0400 Subject: Build: Move `KWSYS_ENCODING_DEFAULT_CODEPAGE` to the config header --- Source/CMakeLists.txt | 3 --- Source/cmConfigure.cmake.h.in | 2 ++ Source/cmWindowsRegistry.h | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 0cb2a57..424cb5f 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -765,9 +765,6 @@ target_link_libraries( ${CMAKE_THREAD_LIBS_INIT} ) -set_property(SOURCE cmProcessOutput.cxx cmWindowsRegistry.cxx APPEND PROPERTY COMPILE_DEFINITIONS - KWSYS_ENCODING_DEFAULT_CODEPAGE=${KWSYS_ENCODING_DEFAULT_CODEPAGE}) - # Check if we can build the Mach-O parser. if(CMake_USE_MACH_PARSER) target_sources( diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in index 7dc9d62..90f3de0 100644 --- a/Source/cmConfigure.cmake.h.in +++ b/Source/cmConfigure.cmake.h.in @@ -39,3 +39,5 @@ #cmakedefine01 CMake_STAT_HAS_ST_MTIM #cmakedefine01 CMake_STAT_HAS_ST_MTIMESPEC + +#cmakedefine KWSYS_ENCODING_DEFAULT_CODEPAGE @KWSYS_ENCODING_DEFAULT_CODEPAGE@ diff --git a/Source/cmWindowsRegistry.h b/Source/cmWindowsRegistry.h index 2eed297..f4a0e7b 100644 --- a/Source/cmWindowsRegistry.h +++ b/Source/cmWindowsRegistry.h @@ -2,6 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #pragma once +#include "cmConfigure.h" // IWYU pragma: keep + #include // IWYU pragma: keep #include #include -- cgit v0.12 From 3b32a1a8208812dde24f5f6be30e7f9361f01cab Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 06:45:30 +0400 Subject: Build: Introduce `ManifestLib` interface library MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … instead of `MANIFEST_FILE` variable. --- Source/CMakeLists.txt | 22 +++++++++++++--------- Source/QtDialog/CMakeLists.txt | 4 ++-- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 424cb5f..67b2fd9 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -71,8 +71,12 @@ configure_file( @ONLY ) +# Add a dummy library and add sources later depends on condition +add_library(ManifestLib INTERFACE) + # # create a library used by the command line and the GUI +# add_library( CMakeLib # Lexers/Parsers @@ -866,7 +870,7 @@ if(WIN32) # Add a manifest file to executables on Windows to allow for # GetVersion to work properly on Windows 8 and above. - set(MANIFEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/cmake.version.manifest) + target_sources(ManifestLib INTERFACE cmake.version.manifest) endif() endif() @@ -902,9 +906,9 @@ set(_tools) if(WIN32 AND NOT CYGWIN) set_source_files_properties(cmcldeps.cxx PROPERTIES COMPILE_DEFINITIONS _WIN32_WINNT=0x0501) - add_executable(cmcldeps cmcldeps.cxx ${MANIFEST_FILE}) + add_executable(cmcldeps cmcldeps.cxx) + target_link_libraries(cmcldeps PRIVATE CMakeLib ManifestLib) list(APPEND _tools cmcldeps) - target_link_libraries(cmcldeps PRIVATE CMakeLib) endif() if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR MATCHES "sparc") @@ -1155,19 +1159,19 @@ if(CPACK_ENABLE_FREEBSD_PKG AND FREEBSD_PKG_INCLUDE_DIRS AND FREEBSD_PKG_LIBRARI endif() # Build CMake executable -add_executable(cmake cmakemain.cxx cmcmd.cxx cmcmd.h ${MANIFEST_FILE}) +add_executable(cmake cmakemain.cxx cmcmd.cxx cmcmd.h) +target_link_libraries(cmake PRIVATE CMakeLib ManifestLib) list(APPEND _tools cmake) -target_link_libraries(cmake PRIVATE CMakeLib) # Build CTest executable -add_executable(ctest ctest.cxx ${MANIFEST_FILE}) +add_executable(ctest ctest.cxx) +target_link_libraries(ctest PRIVATE CTestLib ManifestLib) list(APPEND _tools ctest) -target_link_libraries(ctest PRIVATE CTestLib) # Build CPack executable -add_executable(cpack CPack/cpack.cxx ${MANIFEST_FILE}) +add_executable(cpack CPack/cpack.cxx) +target_link_libraries(cpack PRIVATE CPackLib ManifestLib) list(APPEND _tools cpack) -target_link_libraries(cpack PRIVATE CPackLib) # Curses GUI if(BUILD_CursesDialog) diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index f3859e1..009154c 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -252,8 +252,8 @@ endif() add_library(CMakeGUIMainLib STATIC CMakeSetup.cxx) target_link_libraries(CMakeGUIMainLib PUBLIC CMakeGUILib) -add_executable(cmake-gui WIN32 MACOSX_BUNDLE CMakeGUIExec.cxx ${MANIFEST_FILE}) -target_link_libraries(cmake-gui CMakeGUIMainLib Qt${INSTALLED_QT_VERSION}::Core) +add_executable(cmake-gui WIN32 MACOSX_BUNDLE CMakeGUIExec.cxx) +target_link_libraries(cmake-gui CMakeGUIMainLib ManifestLib Qt${INSTALLED_QT_VERSION}::Core) target_sources(CMakeGUIMainLib INTERFACE $) if(WIN32) -- cgit v0.12 From 89a1e1c1be9ea7519b0c52d30087d95062a091d1 Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 07:11:38 +0400 Subject: Build: Link w/ `OBJECT` library is OK since 3.12 --- Source/CMakeLists.txt | 2 +- Source/QtDialog/CMakeLists.txt | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 67b2fd9..de3ce15 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -1211,7 +1211,7 @@ if(WIN32) add_library(CMakeVersion OBJECT "${CMAKE_CURRENT_BINARY_DIR}/CMakeVersion.rc") set_property(TARGET CMakeVersion PROPERTY INCLUDE_DIRECTORIES "") foreach(_tool IN LISTS _tools) - target_sources(${_tool} PRIVATE $) + target_link_libraries(${_tool} PRIVATE CMakeVersion) endforeach() endif() diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index 009154c..2766db8 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -250,14 +250,19 @@ if(USE_LGPL) endif() add_library(CMakeGUIMainLib STATIC CMakeSetup.cxx) -target_link_libraries(CMakeGUIMainLib PUBLIC CMakeGUILib) +target_link_libraries( + CMakeGUIMainLib + PUBLIC + CMakeGUILib + CMakeGUIQRCLib + $ + ) add_executable(cmake-gui WIN32 MACOSX_BUNDLE CMakeGUIExec.cxx) target_link_libraries(cmake-gui CMakeGUIMainLib ManifestLib Qt${INSTALLED_QT_VERSION}::Core) -target_sources(CMakeGUIMainLib INTERFACE $) if(WIN32) - target_sources(CMakeGUIMainLib INTERFACE $ CMakeSetup.rc) + target_sources(CMakeGUIMainLib INTERFACE CMakeSetup.rc) endif() if(APPLE) target_sources(CMakeGUIMainLib INTERFACE CMakeSetup.icns) -- cgit v0.12 From f31c784a2d1742dbe1cf321c1c0dd225ce3941a0 Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 07:28:08 +0400 Subject: Build: Eliminate one time used variable --- Source/QtDialog/CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index 2766db8..989a929 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -314,12 +314,10 @@ if(APPLE) $/cmake-gui ) endif() -set(CMAKE_INSTALL_DESTINATION_ARGS - BUNDLE DESTINATION "${CMAKE_BUNDLE_LOCATION}" ${COMPONENT}) install(TARGETS cmake-gui RUNTIME DESTINATION bin ${COMPONENT} - ${CMAKE_INSTALL_DESTINATION_ARGS}) + BUNDLE DESTINATION "${CMAKE_BUNDLE_LOCATION}" ${COMPONENT}) if(UNIX AND NOT APPLE) foreach(size IN ITEMS 32 128) -- cgit v0.12 From 626136ad4dbf13f560d8c55c5d50f0488e8db966 Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 07:59:50 +0400 Subject: Build: Use imported `LibUUID::LibUUID` target instead of variables Also, simplify preprocessor condition to enable WIX CPack generator. --- Source/CMakeLists.txt | 36 +++++++++++++++++--------------- Source/CPack/cmCPackConfigure.h.in | 3 +++ Source/CPack/cmCPackGeneratorFactory.cxx | 4 ++-- Source/CPack/cmCPackGeneratorFactory.h | 2 ++ 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index de3ce15..2cf4d1c 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -62,7 +62,6 @@ endif() # configure the .h file configure_file(cmConfigure.cmake.h.in cmConfigure.h) configure_file(cmVersionConfig.h.in cmVersionConfig.h) -configure_file(CPack/cmCPackConfigure.h.in CPack/cmCPackConfigure.h) # Tell CMake executable in the build tree where to find the source tree. configure_file( @@ -1041,18 +1040,14 @@ add_library( CPack/IFW/cmCPackIFWRepository.cxx CPack/IFW/cmCPackIFWRepository.h ) -target_include_directories(CPackLib PUBLIC "${CMake_SOURCE_DIR}/Source/CPack") +target_include_directories( + CPackLib + PUBLIC + "${CMAKE_CURRENT_SOURCE_DIR}/CPack" + "${CMAKE_CURRENT_BINARY_DIR}/CPack" + ) target_link_libraries(CPackLib PUBLIC CMakeLib) -if(CYGWIN) - target_sources( - CPackLib - PUBLIC - CPack/cmCPackCygwinBinaryGenerator.cxx - CPack/cmCPackCygwinSourceGenerator.cxx - ) -endif() - option(CPACK_ENABLE_FREEBSD_PKG "Add FreeBSD pkg(8) generator to CPack." OFF) if(UNIX) @@ -1089,9 +1084,17 @@ if(UNIX) endif() if(CYGWIN) + target_sources( + CPackLib + PUBLIC + CPack/cmCPackCygwinBinaryGenerator.cxx + CPack/cmCPackCygwinSourceGenerator.cxx + ) find_package(LibUUID) endif() -if(WIN32 OR (CYGWIN AND LibUUID_FOUND)) + +if(WIN32 OR (CYGWIN AND TARGET LibUUID::LibUUID)) + set(ENABLE_BUILD_WIX_GENERATOR 1) target_sources( CPackLib PUBLIC @@ -1118,6 +1121,7 @@ if(WIN32 OR (CYGWIN AND LibUUID_FOUND)) CPack/WiX/cmWIXSourceWriter.cxx CPack/WiX/cmWIXSourceWriter.h ) + target_link_libraries(CPackLib PUBLIC $) endif() if(APPLE) @@ -1147,16 +1151,14 @@ if(APPLE) "See CMakeFiles/CMakeError.log for details of the failure.") endif() endif() -if(CYGWIN AND LibUUID_FOUND) - target_include_directories(CPackLib PUBLIC ${LibUUID_INCLUDE_DIRS}) - target_link_libraries(CPackLib PUBLIC ${LibUUID_LIBRARIES}) - set_property(SOURCE CPack/cmCPackGeneratorFactory.cxx PROPERTY COMPILE_DEFINITIONS HAVE_LIBUUID) -endif() if(CPACK_ENABLE_FREEBSD_PKG AND FREEBSD_PKG_INCLUDE_DIRS AND FREEBSD_PKG_LIBRARIES) target_include_directories(CPackLib PUBLIC ${FREEBSD_PKG_INCLUDE_DIRS}) target_link_libraries(CPackLib PUBLIC ${FREEBSD_PKG_LIBRARIES}) target_compile_definitions(CPackLib PUBLIC HAVE_FREEBSD_PKG) endif() +# Render config header file for CPackLib +configure_file(CPack/cmCPackConfigure.h.in CPack/cmCPackConfigure.h) + # Build CMake executable add_executable(cmake cmakemain.cxx cmcmd.cxx cmcmd.h) diff --git a/Source/CPack/cmCPackConfigure.h.in b/Source/CPack/cmCPackConfigure.h.in index 8ac1661..128784a 100644 --- a/Source/CPack/cmCPackConfigure.h.in +++ b/Source/CPack/cmCPackConfigure.h.in @@ -1,2 +1,5 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ +#pragma once + +#cmakedefine01 ENABLE_BUILD_WIX_GENERATOR diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx index 725ea8a..ef58870 100644 --- a/Source/CPack/cmCPackGeneratorFactory.cxx +++ b/Source/CPack/cmCPackGeneratorFactory.cxx @@ -34,7 +34,7 @@ # include "cmCPackRPMGenerator.h" #endif -#if defined(_WIN32) || (defined(__CYGWIN__) && defined(HAVE_LIBUUID)) +#if ENABLE_BUILD_WIX_GENERATOR # include "WiX/cmCPackWIXGenerator.h" #endif @@ -80,7 +80,7 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory() cmCPackCygwinSourceGenerator::CreateGenerator); } #endif -#if defined(_WIN32) || (defined(__CYGWIN__) && defined(HAVE_LIBUUID)) +#if ENABLE_BUILD_WIX_GENERATOR if (cmCPackWIXGenerator::CanGenerate()) { this->RegisterGenerator("WIX", "MSI file format via WiX tools", cmCPackWIXGenerator::CreateGenerator); diff --git a/Source/CPack/cmCPackGeneratorFactory.h b/Source/CPack/cmCPackGeneratorFactory.h index f3e25a6..52c1b5c 100644 --- a/Source/CPack/cmCPackGeneratorFactory.h +++ b/Source/CPack/cmCPackGeneratorFactory.h @@ -8,6 +8,8 @@ #include #include +#include "cmCPackConfigure.h" // IWYU pragma: keep + class cmCPackGenerator; class cmCPackLog; -- cgit v0.12 From 7df955315b6de04333c3c23a1601e3af4911ed32 Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 08:21:52 +0400 Subject: Build: Add `ENABLE_BUILD_FREEBSD_PKG` to `cmCPackConfigure.h` --- Source/CMakeLists.txt | 10 ++++------ Source/CPack/cmCPackConfigure.h.in | 1 + Source/CPack/cmCPackGeneratorFactory.cxx | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 2cf4d1c..ec581e8 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -1049,7 +1049,6 @@ target_include_directories( target_link_libraries(CPackLib PUBLIC CMakeLib) option(CPACK_ENABLE_FREEBSD_PKG "Add FreeBSD pkg(8) generator to CPack." OFF) - if(UNIX) target_sources( CPackLib @@ -1070,7 +1069,10 @@ if(UNIX) pkg DOC "FreeBSD pkg(8) library") if(FREEBSD_PKG_LIBRARIES) + set(ENABLE_BUILD_FREEBSD_PKG 1) target_sources(CPackLib PUBLIC CPack/cmCPackFreeBSDGenerator.cxx) + target_include_directories(CPackLib PUBLIC ${FREEBSD_PKG_INCLUDE_DIRS}) + target_link_libraries(CPackLib PUBLIC ${FREEBSD_PKG_LIBRARIES}) endif() endif() @@ -1151,11 +1153,7 @@ if(APPLE) "See CMakeFiles/CMakeError.log for details of the failure.") endif() endif() -if(CPACK_ENABLE_FREEBSD_PKG AND FREEBSD_PKG_INCLUDE_DIRS AND FREEBSD_PKG_LIBRARIES) - target_include_directories(CPackLib PUBLIC ${FREEBSD_PKG_INCLUDE_DIRS}) - target_link_libraries(CPackLib PUBLIC ${FREEBSD_PKG_LIBRARIES}) - target_compile_definitions(CPackLib PUBLIC HAVE_FREEBSD_PKG) -endif() + # Render config header file for CPackLib configure_file(CPack/cmCPackConfigure.h.in CPack/cmCPackConfigure.h) diff --git a/Source/CPack/cmCPackConfigure.h.in b/Source/CPack/cmCPackConfigure.h.in index 128784a..a5e36d3 100644 --- a/Source/CPack/cmCPackConfigure.h.in +++ b/Source/CPack/cmCPackConfigure.h.in @@ -3,3 +3,4 @@ #pragma once #cmakedefine01 ENABLE_BUILD_WIX_GENERATOR +#cmakedefine01 ENABLE_BUILD_FREEBSD_PKG diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx index ef58870..efb94b9 100644 --- a/Source/CPack/cmCPackGeneratorFactory.cxx +++ b/Source/CPack/cmCPackGeneratorFactory.cxx @@ -6,7 +6,7 @@ #include #include "IFW/cmCPackIFWGenerator.h" -#ifdef HAVE_FREEBSD_PKG +#if ENABLE_BUILD_FREEBSD_PKG # include "cmCPackFreeBSDGenerator.h" #endif #include "cmCPackArchiveGenerator.h" @@ -119,7 +119,7 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory() cmCPackRPMGenerator::CreateGenerator); } #endif -#ifdef HAVE_FREEBSD_PKG +#if ENABLE_BUILD_FREEBSD_PKG if (cmCPackFreeBSDGenerator::CanGenerate()) { this->RegisterGenerator("FREEBSD", "FreeBSD pkg(8) packages", cmCPackFreeBSDGenerator::CreateGenerator); -- cgit v0.12 From 98e8b1755b2b8b3d9ff781ca997e8af28dc1ca8d Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 08:28:22 +0400 Subject: Build: Move `HAVE_CoreServices` to `cmCPackConfigure.h` --- Source/CMakeLists.txt | 1 - Source/CPack/cmCPackConfigure.h.in | 1 + Source/CPack/cmCPackDragNDropGenerator.cxx | 7 ++++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index ec581e8..0afdf4c 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -1144,7 +1144,6 @@ if(APPLE) # If it does not work, build with reduced functionality and warn. check_include_file("CoreServices/CoreServices.h" HAVE_CoreServices) if(HAVE_CoreServices) - set_property(SOURCE CPack/cmCPackDragNDropGenerator.cxx PROPERTY COMPILE_DEFINITIONS HAVE_CoreServices) target_link_libraries(CPackLib PUBLIC "-framework CoreServices") else() message(WARNING "This compiler does not appear to support\n" diff --git a/Source/CPack/cmCPackConfigure.h.in b/Source/CPack/cmCPackConfigure.h.in index a5e36d3..2c1302d 100644 --- a/Source/CPack/cmCPackConfigure.h.in +++ b/Source/CPack/cmCPackConfigure.h.in @@ -4,3 +4,4 @@ #cmakedefine01 ENABLE_BUILD_WIX_GENERATOR #cmakedefine01 ENABLE_BUILD_FREEBSD_PKG +#cmakedefine01 HAVE_CoreServices diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index 0f7acfb..0579066 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -14,6 +14,7 @@ #include "cmsys/FStream.hxx" #include "cmsys/RegularExpression.hxx" +#include "cmCPackConfigure.h" #include "cmCPackGenerator.h" #include "cmCPackLog.h" #include "cmDuration.h" @@ -23,7 +24,7 @@ #include "cmValue.h" #include "cmXMLWriter.h" -#ifdef HAVE_CoreServices +#if HAVE_CoreServices // For the old LocaleStringToLangAndRegionCodes() function, to convert // to the old Script Manager RegionCode values needed for the 'LPic' data // structure used for generating multi-lingual SLAs. @@ -590,7 +591,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, kCFStringEncodingMacRoman); LangCode lang = 0; RegionCode region = 0; -#ifdef HAVE_CoreServices +#if HAVE_CoreServices OSStatus err = LocaleStringToLangAndRegionCodes(iso_language_cstr, &lang, ®ion); if (err != noErr) @@ -601,7 +602,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, << iso_language_cstr << std::endl); return 0; } -#ifdef HAVE_CoreServices +#if HAVE_CoreServices header_data.push_back(region); header_data.push_back(i); header_data.push_back(0); -- cgit v0.12 From 35ad2c6e5f232b2446ce11165e2076a8b0e7ce69 Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 08:37:20 +0400 Subject: Build: Replace `foreach` with 2 `set` calls --- Source/CMakeLists.txt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 0afdf4c..6c2daec 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -36,13 +36,8 @@ if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Da set(CMAKE_USE_WMAKE 1) endif() -foreach(check IN ITEMS STAT_HAS_ST_MTIM STAT_HAS_ST_MTIMESPEC) - if(KWSYS_CXX_${check}_COMPILED) # abuse KWSys check cache entry - set(CMake_${check} 1) - else() - set(CMake_${check} 0) - endif() -endforeach() +set(CMake_STAT_HAS_ST_MTIM ${KWSYS_CXX_STAT_HAS_ST_MTIM_COMPILED}) +set(CMake_STAT_HAS_ST_MTIMESPEC ${KWSYS_CXX_STAT_HAS_ST_MTIMESPEC_COMPILED}) set(EXECUTABLE_OUTPUT_PATH ${CMake_BIN_DIR}) -- cgit v0.12 From 20b9808f90329d0d05d8fe837cea86b4ee194272 Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 08:40:40 +0400 Subject: Build: Use `cmstd` target instead of variable `CMAKE_STD_LIBRARY` --- CMakeLists.txt | 1 - Source/CMakeLists.txt | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a50e222..4179ce5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -407,7 +407,6 @@ macro(CMAKE_BUILD_UTILITIES) #--------------------------------------------------------------------- # Build CMake std library for CMake and CTest. - set(CMAKE_STD_LIBRARY cmstd) add_subdirectory(Utilities/std) CMAKE_SET_TARGET_FOLDER(cmstd "Utilities/std") diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 6c2daec..da7f015 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -751,8 +751,8 @@ target_include_directories( target_link_libraries( CMakeLib PUBLIC + cmstd cmsys - ${CMAKE_STD_LIBRARY} ${CMAKE_EXPAT_LIBRARIES} ${CMAKE_ZLIB_LIBRARIES} ${CMAKE_TAR_LIBRARIES} ${CMAKE_CURL_LIBRARIES} -- cgit v0.12 From 4c6a47c6b6060c194f8b850f394ab2c831252f67 Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 08:47:58 +0400 Subject: Build: Extract `CMAKE_BUILD_UTILITIES` macro into a separate include The macro was one time used with the comment "Simply to improve readability...". The result file doesn't have a macro anymore and just included into the root `CMakeLists.txt`. --- CMakeLists.txt | 388 +------------------------------ Source/CMakeLists.txt | 3 +- Source/Modules/CMakeBuildUtilities.cmake | 383 ++++++++++++++++++++++++++++++ 3 files changed, 388 insertions(+), 386 deletions(-) create mode 100644 Source/Modules/CMakeBuildUtilities.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 4179ce5..ae8d05a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -329,389 +329,6 @@ macro(CMAKE_SET_TARGET_FOLDER tgt folder) endif() endmacro() - -#----------------------------------------------------------------------- -# a macro to build the utilities used by CMake -# Simply to improve readability of the main script. -#----------------------------------------------------------------------- -macro(CMAKE_BUILD_UTILITIES) - find_package(Threads) - - # Suppress unnecessary checks in third-party code. - include(Utilities/cmThirdPartyChecks.cmake) - - #--------------------------------------------------------------------- - # Create the kwsys library for CMake. - set(KWSYS_NAMESPACE cmsys) - set(KWSYS_USE_SystemTools 1) - set(KWSYS_USE_Directory 1) - set(KWSYS_USE_RegularExpression 1) - set(KWSYS_USE_Base64 1) - set(KWSYS_USE_MD5 1) - set(KWSYS_USE_Process 1) - set(KWSYS_USE_CommandLineArguments 1) - set(KWSYS_USE_ConsoleBuf 1) - set(KWSYS_HEADER_ROOT ${CMake_BINARY_DIR}/Source) - set(KWSYS_INSTALL_DOC_DIR "${CMAKE_DOC_DIR}") - if(CMake_NO_CXX_STANDARD) - set(KWSYS_CXX_STANDARD "") - endif() - if(CMake_NO_SELF_BACKTRACE) - set(KWSYS_NO_EXECINFO 1) - endif() - if(WIN32) - # FIXME: Teach KWSys to hard-code these checks on Windows. - set(KWSYS_C_HAS_CLOCK_GETTIME_MONOTONIC_COMPILED 0) - set(KWSYS_C_HAS_PTRDIFF_T_COMPILED 1) - set(KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H_COMPILED 1) - set(KWSYS_CXX_HAS_RLIMIT64_COMPILED 0) - set(KWSYS_CXX_HAS_SETENV_COMPILED 0) - set(KWSYS_CXX_HAS_UNSETENV_COMPILED 0) - set(KWSYS_CXX_HAS_UTIMENSAT_COMPILED 0) - set(KWSYS_CXX_HAS_UTIMES_COMPILED 0) - set(KWSYS_CXX_STAT_HAS_ST_MTIM_COMPILED 0) - set(KWSYS_CXX_STAT_HAS_ST_MTIMESPEC_COMPILED 0) - set(KWSYS_STL_HAS_WSTRING_COMPILED 1) - set(KWSYS_SYS_HAS_IFADDRS_H 0) - endif() - add_subdirectory(Source/kwsys) - set(kwsys_folder "Utilities/KWSys") - CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE} "${kwsys_folder}") - CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}_c "${kwsys_folder}") - if(BUILD_TESTING) - CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestDynload "${kwsys_folder}") - CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestProcess "${kwsys_folder}") - CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestsC "${kwsys_folder}") - CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestsCxx "${kwsys_folder}") - CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestSharedForward "${kwsys_folder}") - endif() - - #--------------------------------------------------------------------- - # Setup third-party libraries. - # Everything in the tree should be able to include files from the - # Utilities directory. - if((CMAKE_SYSTEM_NAME STREQUAL "AIX" OR CMAKE_SYSTEM_NAME STREQUAL "OS400") AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - # using -isystem option generate error "template with C linkage" - include_directories("${CMake_SOURCE_DIR}/Utilities/std") - else() - include_directories(SYSTEM "${CMake_SOURCE_DIR}/Utilities/std") - endif() - - include_directories("${CMake_BINARY_DIR}/Utilities") - if((CMAKE_SYSTEM_NAME STREQUAL "AIX" OR CMAKE_SYSTEM_NAME STREQUAL "OS400") AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - # using -isystem option generate error "template with C linkage" - include_directories("${CMake_SOURCE_DIR}/Utilities") - else() - include_directories(SYSTEM "${CMake_SOURCE_DIR}/Utilities") - endif() - - #--------------------------------------------------------------------- - # Build CMake std library for CMake and CTest. - add_subdirectory(Utilities/std) - CMAKE_SET_TARGET_FOLDER(cmstd "Utilities/std") - - # check for the use of system libraries versus builtin ones - # (a macro defined in this file) - CMAKE_HANDLE_SYSTEM_LIBRARIES() - - if(CMAKE_USE_SYSTEM_KWIML) - find_package(KWIML 1.0) - if(NOT KWIML_FOUND) - message(FATAL_ERROR "CMAKE_USE_SYSTEM_KWIML is ON but KWIML is not found!") - endif() - set(CMake_KWIML_LIBRARIES kwiml::kwiml) - else() - set(CMake_KWIML_LIBRARIES "") - if(BUILD_TESTING) - set(KWIML_TEST_ENABLE 1) - endif() - add_subdirectory(Utilities/KWIML) - endif() - - if(CMAKE_USE_SYSTEM_LIBRHASH) - find_package(LibRHash) - if(NOT LibRHash_FOUND) - message(FATAL_ERROR - "CMAKE_USE_SYSTEM_LIBRHASH is ON but LibRHash is not found!") - endif() - set(CMAKE_LIBRHASH_LIBRARIES LibRHash::LibRHash) - else() - set(CMAKE_LIBRHASH_LIBRARIES cmlibrhash) - add_subdirectory(Utilities/cmlibrhash) - CMAKE_SET_TARGET_FOLDER(cmlibrhash "Utilities/3rdParty") - endif() - - #--------------------------------------------------------------------- - # Build zlib library for Curl, CMake, and CTest. - set(CMAKE_ZLIB_HEADER "cm_zlib.h") - if(CMAKE_USE_SYSTEM_ZLIB) - find_package(ZLIB) - if(NOT ZLIB_FOUND) - message(FATAL_ERROR - "CMAKE_USE_SYSTEM_ZLIB is ON but a zlib is not found!") - endif() - set(CMAKE_ZLIB_INCLUDES ${ZLIB_INCLUDE_DIR}) - set(CMAKE_ZLIB_LIBRARIES ${ZLIB_LIBRARIES}) - else() - set(CMAKE_ZLIB_INCLUDES ${CMake_SOURCE_DIR}/Utilities) - set(CMAKE_ZLIB_LIBRARIES cmzlib) - set(WITHOUT_ZLIB_DLL "") - set(WITHOUT_ZLIB_DLL_WITH_LIB cmzlib) - set(ZLIB_DLL "") - set(ZLIB_DLL_WITH_LIB cmzlib) - set(ZLIB_WINAPI "") - set(ZLIB_WINAPI_COMPILED 0) - set(ZLIB_WINAPI_WITH_LIB cmzlib) - add_subdirectory(Utilities/cmzlib) - CMAKE_SET_TARGET_FOLDER(cmzlib "Utilities/3rdParty") - endif() - - #--------------------------------------------------------------------- - # Build Curl library for CTest. - if(CMAKE_USE_SYSTEM_CURL) - find_package(CURL) - if(NOT CURL_FOUND) - message(FATAL_ERROR - "CMAKE_USE_SYSTEM_CURL is ON but a curl is not found!") - endif() - set(CMAKE_CURL_INCLUDES ${CURL_INCLUDE_DIRS}) - set(CMAKE_CURL_LIBRARIES ${CURL_LIBRARIES}) - else() - set(CURL_SPECIAL_ZLIB_H ${CMAKE_ZLIB_HEADER}) - set(CURL_SPECIAL_LIBZ_INCLUDES ${CMAKE_ZLIB_INCLUDES}) - set(CURL_SPECIAL_LIBZ ${CMAKE_ZLIB_LIBRARIES}) - set(CMAKE_CURL_INCLUDES) - set(CMAKE_CURL_LIBRARIES cmcurl) - if(CMAKE_TESTS_CDASH_SERVER) - set(CMAKE_CURL_TEST_URL "${CMAKE_TESTS_CDASH_SERVER}/user.php") - endif() - set(_CMAKE_USE_OPENSSL_DEFAULT OFF) - if(NOT DEFINED CMAKE_USE_OPENSSL AND NOT WIN32 AND NOT APPLE - AND CMAKE_SYSTEM_NAME MATCHES "(Linux|FreeBSD)") - set(_CMAKE_USE_OPENSSL_DEFAULT ON) - endif() - option(CMAKE_USE_OPENSSL "Use OpenSSL." ${_CMAKE_USE_OPENSSL_DEFAULT}) - mark_as_advanced(CMAKE_USE_OPENSSL) - if(CMAKE_USE_OPENSSL) - set(CURL_CA_BUNDLE "" CACHE FILEPATH "Path to SSL CA Certificate Bundle") - set(CURL_CA_PATH "" CACHE PATH "Path to SSL CA Certificate Directory") - mark_as_advanced(CURL_CA_BUNDLE CURL_CA_PATH) - endif() - if(NOT CMAKE_USE_SYSTEM_NGHTTP2) - # Tell curl's FindNGHTTP2 module to use our library. - set(NGHTTP2_LIBRARY cmnghttp2) - set(NGHTTP2_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmnghttp2/lib/includes) - endif() - add_subdirectory(Utilities/cmcurl) - CMAKE_SET_TARGET_FOLDER(cmcurl "Utilities/3rdParty") - CMAKE_SET_TARGET_FOLDER(LIBCURL "Utilities/3rdParty") - if(NOT CMAKE_USE_SYSTEM_NGHTTP2) - # Configure after curl to re-use some check results. - add_subdirectory(Utilities/cmnghttp2) - CMAKE_SET_TARGET_FOLDER(cmnghttp2 "Utilities/3rdParty") - endif() - endif() - - #--------------------------------------------------------------------- - # Build expat library for CMake, CTest, and libarchive. - if(CMAKE_USE_SYSTEM_EXPAT) - find_package(EXPAT) - if(NOT EXPAT_FOUND) - message(FATAL_ERROR - "CMAKE_USE_SYSTEM_EXPAT is ON but a expat is not found!") - endif() - set(CMAKE_EXPAT_INCLUDES ${EXPAT_INCLUDE_DIRS}) - set(CMAKE_EXPAT_LIBRARIES ${EXPAT_LIBRARIES}) - else() - set(CMAKE_EXPAT_INCLUDES) - set(CMAKE_EXPAT_LIBRARIES cmexpat) - add_subdirectory(Utilities/cmexpat) - CMAKE_SET_TARGET_FOLDER(cmexpat "Utilities/3rdParty") - endif() - - #--------------------------------------------------------------------- - # Build or use system libbz2 for libarchive. - if(NOT CMAKE_USE_SYSTEM_LIBARCHIVE) - if(CMAKE_USE_SYSTEM_BZIP2) - find_package(BZip2) - else() - set(BZIP2_INCLUDE_DIR - "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmbzip2") - set(BZIP2_LIBRARIES cmbzip2) - set(BZIP2_NEED_PREFIX "") - set(USE_BZIP2_DLL "") - set(USE_BZIP2_DLL_WITH_LIB cmbzip2) - set(USE_BZIP2_STATIC "") - set(USE_BZIP2_STATIC_WITH_LIB cmbzip2) - add_subdirectory(Utilities/cmbzip2) - CMAKE_SET_TARGET_FOLDER(cmbzip2 "Utilities/3rdParty") - endif() - endif() - - #--------------------------------------------------------------------- - # Build or use system zstd for libarchive. - if(NOT CMAKE_USE_SYSTEM_LIBARCHIVE) - if(NOT CMAKE_USE_SYSTEM_ZSTD) - set(ZSTD_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmzstd") - set(ZSTD_LIBRARY cmzstd) - add_subdirectory(Utilities/cmzstd) - CMAKE_SET_TARGET_FOLDER(cmzstd "Utilities/3rdParty") - endif() - endif() - - #--------------------------------------------------------------------- - # Build or use system liblzma for libarchive. - if(NOT CMAKE_USE_SYSTEM_LIBARCHIVE) - if(CMAKE_USE_SYSTEM_LIBLZMA) - find_package(LibLZMA) - if(NOT LIBLZMA_FOUND) - message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBLZMA is ON but LibLZMA is not found!") - endif() - else() - add_subdirectory(Utilities/cmliblzma) - CMAKE_SET_TARGET_FOLDER(cmliblzma "Utilities/3rdParty") - set(LIBLZMA_HAS_AUTO_DECODER 1) - set(LIBLZMA_HAS_EASY_ENCODER 1) - set(LIBLZMA_HAS_LZMA_PRESET 1) - set(LIBLZMA_INCLUDE_DIR - "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmliblzma/liblzma/api") - set(LIBLZMA_LIBRARY cmliblzma) - set(HAVE_LZMA_STREAM_ENCODER_MT 1) - endif() - endif() - - #--------------------------------------------------------------------- - # Build or use system libarchive for CMake and CTest. - if(CMAKE_USE_SYSTEM_LIBARCHIVE) - find_package(LibArchive 3.3.3) - if(NOT LibArchive_FOUND) - message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBARCHIVE is ON but LibArchive is not found!") - endif() - set(CMAKE_TAR_INCLUDES ${LibArchive_INCLUDE_DIRS}) - set(CMAKE_TAR_LIBRARIES ${LibArchive_LIBRARIES}) - else() - set(EXPAT_INCLUDE_DIR ${CMAKE_EXPAT_INCLUDES}) - set(EXPAT_LIBRARY ${CMAKE_EXPAT_LIBRARIES}) - set(ZLIB_INCLUDE_DIR ${CMAKE_ZLIB_INCLUDES}) - set(ZLIB_LIBRARY ${CMAKE_ZLIB_LIBRARIES}) - add_compile_definitions(LIBARCHIVE_STATIC) - set(ENABLE_MBEDTLS OFF) - set(ENABLE_NETTLE OFF) - if(DEFINED CMAKE_USE_OPENSSL) - set(ENABLE_OPENSSL "${CMAKE_USE_OPENSSL}") - else() - set(ENABLE_OPENSSL OFF) - endif() - set(ENABLE_LIBB2 OFF) - set(ENABLE_LZ4 OFF) - set(ENABLE_LZO OFF) - set(ENABLE_LZMA ON) - set(ENABLE_ZSTD ON) - set(ENABLE_ZLIB ON) - set(ENABLE_BZip2 ON) - set(ENABLE_LIBXML2 OFF) - set(ENABLE_EXPAT OFF) - set(ENABLE_PCREPOSIX OFF) - set(ENABLE_LibGCC OFF) - set(ENABLE_CNG OFF) - set(ENABLE_TAR OFF) - set(ENABLE_TAR_SHARED OFF) - set(ENABLE_CPIO OFF) - set(ENABLE_CPIO_SHARED OFF) - set(ENABLE_CAT OFF) - set(ENABLE_CAT_SHARED OFF) - set(ENABLE_XATTR OFF) - set(ENABLE_ACL OFF) - set(ENABLE_ICONV OFF) - set(ENABLE_TEST OFF) - set(ENABLE_COVERAGE OFF) - set(ENABLE_INSTALL OFF) - set(POSIX_REGEX_LIB "" CACHE INTERNAL "libarchive: No POSIX regular expression support") - set(ENABLE_SAFESEH "" CACHE INTERNAL "libarchive: No /SAFESEH linker flag") - set(WINDOWS_VERSION "WIN7" CACHE INTERNAL "libarchive: Set Windows version to use (Windows only)") - add_subdirectory(Utilities/cmlibarchive) - CMAKE_SET_TARGET_FOLDER(cmlibarchive "Utilities/3rdParty") - set(CMAKE_TAR_LIBRARIES cmlibarchive ${BZIP2_LIBRARIES}) - endif() - - #--------------------------------------------------------------------- - # Build jsoncpp library. - if(CMAKE_USE_SYSTEM_JSONCPP) - find_package(JsonCpp 1.6.0) - if(NOT JsonCpp_FOUND) - message(FATAL_ERROR - "CMAKE_USE_SYSTEM_JSONCPP is ON but a JsonCpp is not found!") - endif() - if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|LCC|Clang") - set_property(TARGET JsonCpp::JsonCpp APPEND PROPERTY - INTERFACE_COMPILE_OPTIONS -Wno-deprecated-declarations) - endif() - set(CMAKE_JSONCPP_LIBRARIES JsonCpp::JsonCpp) - else() - set(CMAKE_JSONCPP_LIBRARIES cmjsoncpp) - add_subdirectory(Utilities/cmjsoncpp) - CMAKE_SET_TARGET_FOLDER(cmjsoncpp "Utilities/3rdParty") - endif() - - #--------------------------------------------------------------------- - # Build libuv library. - if(CMAKE_USE_SYSTEM_LIBUV) - if(WIN32) - find_package(LibUV 1.38.0) - else() - find_package(LibUV 1.28.0) - endif() - if(NOT LIBUV_FOUND) - message(FATAL_ERROR - "CMAKE_USE_SYSTEM_LIBUV is ON but a libuv is not found!") - endif() - set(CMAKE_LIBUV_LIBRARIES LibUV::LibUV) - else() - set(CMAKE_LIBUV_LIBRARIES cmlibuv) - add_subdirectory(Utilities/cmlibuv) - CMAKE_SET_TARGET_FOLDER(cmlibuv "Utilities/3rdParty") - endif() - - #--------------------------------------------------------------------- - # Use curses? - if(NOT DEFINED BUILD_CursesDialog) - if(UNIX) - include(${CMake_SOURCE_DIR}/Source/Checks/Curses.cmake) - set(BUILD_CursesDialog_DEFAULT "${CMakeCheckCurses_COMPILED}") - elseif(WIN32) - set(BUILD_CursesDialog_DEFAULT "OFF") - endif() - option(BUILD_CursesDialog "Build the CMake Curses Dialog ccmake" "${BUILD_CursesDialog_DEFAULT}") - endif() - if(BUILD_CursesDialog) - if(UNIX) - set(CURSES_NEED_NCURSES TRUE) - find_package(Curses) - if(NOT CURSES_FOUND) - message(WARNING - "'ccmake' will not be built because Curses was not found.\n" - "Turn off BUILD_CursesDialog to suppress this message." - ) - set(BUILD_CursesDialog 0) - endif() - elseif(WIN32) - # FIXME: Add support for system-provided pdcurses. - add_subdirectory(Utilities/cmpdcurses) - set(CURSES_LIBRARY cmpdcurses) - set(CURSES_INCLUDE_PATH "") # cmpdcurses has usage requirements - set(CMAKE_USE_SYSTEM_FORM 0) - set(HAVE_CURSES_USE_DEFAULT_COLORS 1) - endif() - endif() - if(BUILD_CursesDialog) - if(NOT CMAKE_USE_SYSTEM_FORM) - add_subdirectory(Source/CursesDialog/form) - elseif(NOT CURSES_FORM_LIBRARY) - message(FATAL_ERROR "CMAKE_USE_SYSTEM_FORM in ON but CURSES_FORM_LIBRARY is not set!") - endif() - endif() -endmacro() - #----------------------------------------------------------------------- if(NOT CMake_TEST_EXTERNAL_CMAKE) if(CMAKE_CXX_PLATFORM_ID MATCHES "OpenBSD") @@ -792,8 +409,9 @@ if(CMake_TEST_EXTERNAL_CMAKE) endif() if(NOT CMake_TEST_EXTERNAL_CMAKE) - # build the utilities (a macro defined in this file) - CMAKE_BUILD_UTILITIES() + find_package(Threads) + # build the utilities + include(CMakeBuildUtilities) if(BUILD_QtDialog) if(APPLE) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index da7f015..9357fdf 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -753,7 +753,8 @@ target_link_libraries( PUBLIC cmstd cmsys - ${CMAKE_EXPAT_LIBRARIES} ${CMAKE_ZLIB_LIBRARIES} + ${CMAKE_EXPAT_LIBRARIES} + ${CMAKE_ZLIB_LIBRARIES} ${CMAKE_TAR_LIBRARIES} ${CMAKE_CURL_LIBRARIES} ${CMAKE_JSONCPP_LIBRARIES} diff --git a/Source/Modules/CMakeBuildUtilities.cmake b/Source/Modules/CMakeBuildUtilities.cmake new file mode 100644 index 0000000..4823adf --- /dev/null +++ b/Source/Modules/CMakeBuildUtilities.cmake @@ -0,0 +1,383 @@ +#----------------------------------------------------------------------- +# Build the utilities used by CMake +# +# Originally it was a macro in the root `CMakeLists.txt` with the comment +# "Simply to improve readability...". +# However, as part of the modernization refactoring it was moved into a +# separate file cuz adding library alises wasn't possible inside the +# macro. +#----------------------------------------------------------------------- + +# Suppress unnecessary checks in third-party code. +include(Utilities/cmThirdPartyChecks.cmake) + +#--------------------------------------------------------------------- +# Create the kwsys library for CMake. +set(KWSYS_NAMESPACE cmsys) +set(KWSYS_USE_SystemTools 1) +set(KWSYS_USE_Directory 1) +set(KWSYS_USE_RegularExpression 1) +set(KWSYS_USE_Base64 1) +set(KWSYS_USE_MD5 1) +set(KWSYS_USE_Process 1) +set(KWSYS_USE_CommandLineArguments 1) +set(KWSYS_USE_ConsoleBuf 1) +set(KWSYS_HEADER_ROOT ${CMake_BINARY_DIR}/Source) +set(KWSYS_INSTALL_DOC_DIR "${CMAKE_DOC_DIR}") +if(CMake_NO_CXX_STANDARD) + set(KWSYS_CXX_STANDARD "") +endif() +if(CMake_NO_SELF_BACKTRACE) + set(KWSYS_NO_EXECINFO 1) +endif() +if(WIN32) + # FIXME: Teach KWSys to hard-code these checks on Windows. + set(KWSYS_C_HAS_CLOCK_GETTIME_MONOTONIC_COMPILED 0) + set(KWSYS_C_HAS_PTRDIFF_T_COMPILED 1) + set(KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H_COMPILED 1) + set(KWSYS_CXX_HAS_RLIMIT64_COMPILED 0) + set(KWSYS_CXX_HAS_SETENV_COMPILED 0) + set(KWSYS_CXX_HAS_UNSETENV_COMPILED 0) + set(KWSYS_CXX_HAS_UTIMENSAT_COMPILED 0) + set(KWSYS_CXX_HAS_UTIMES_COMPILED 0) + set(KWSYS_CXX_STAT_HAS_ST_MTIM_COMPILED 0) + set(KWSYS_CXX_STAT_HAS_ST_MTIMESPEC_COMPILED 0) + set(KWSYS_STL_HAS_WSTRING_COMPILED 1) + set(KWSYS_SYS_HAS_IFADDRS_H 0) +endif() +add_subdirectory(Source/kwsys) +set(kwsys_folder "Utilities/KWSys") +CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE} "${kwsys_folder}") +CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}_c "${kwsys_folder}") +if(BUILD_TESTING) + CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestDynload "${kwsys_folder}") + CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestProcess "${kwsys_folder}") + CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestsC "${kwsys_folder}") + CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestsCxx "${kwsys_folder}") + CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestSharedForward "${kwsys_folder}") +endif() + +#--------------------------------------------------------------------- +# Setup third-party libraries. +# Everything in the tree should be able to include files from the +# Utilities directory. +if((CMAKE_SYSTEM_NAME STREQUAL "AIX" OR CMAKE_SYSTEM_NAME STREQUAL "OS400") AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # using -isystem option generate error "template with C linkage" + include_directories("${CMake_SOURCE_DIR}/Utilities/std") +else() + include_directories(SYSTEM "${CMake_SOURCE_DIR}/Utilities/std") +endif() + +include_directories("${CMake_BINARY_DIR}/Utilities") +if((CMAKE_SYSTEM_NAME STREQUAL "AIX" OR CMAKE_SYSTEM_NAME STREQUAL "OS400") AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # using -isystem option generate error "template with C linkage" + include_directories("${CMake_SOURCE_DIR}/Utilities") +else() + include_directories(SYSTEM "${CMake_SOURCE_DIR}/Utilities") +endif() + +#--------------------------------------------------------------------- +# Build CMake std library for CMake and CTest. +add_subdirectory(Utilities/std) +CMAKE_SET_TARGET_FOLDER(cmstd "Utilities/std") + +# check for the use of system libraries versus builtin ones +# (a macro defined in this file) +CMAKE_HANDLE_SYSTEM_LIBRARIES() + +if(CMAKE_USE_SYSTEM_KWIML) + find_package(KWIML 1.0) + if(NOT KWIML_FOUND) + message(FATAL_ERROR "CMAKE_USE_SYSTEM_KWIML is ON but KWIML is not found!") + endif() + set(CMake_KWIML_LIBRARIES kwiml::kwiml) +else() + set(CMake_KWIML_LIBRARIES "") + if(BUILD_TESTING) + set(KWIML_TEST_ENABLE 1) + endif() + add_subdirectory(Utilities/KWIML) +endif() + +if(CMAKE_USE_SYSTEM_LIBRHASH) + find_package(LibRHash) + if(NOT LibRHash_FOUND) + message(FATAL_ERROR + "CMAKE_USE_SYSTEM_LIBRHASH is ON but LibRHash is not found!") + endif() + set(CMAKE_LIBRHASH_LIBRARIES LibRHash::LibRHash) +else() + set(CMAKE_LIBRHASH_LIBRARIES cmlibrhash) + add_subdirectory(Utilities/cmlibrhash) + CMAKE_SET_TARGET_FOLDER(cmlibrhash "Utilities/3rdParty") +endif() + +#--------------------------------------------------------------------- +# Build zlib library for Curl, CMake, and CTest. +set(CMAKE_ZLIB_HEADER "cm_zlib.h") +if(CMAKE_USE_SYSTEM_ZLIB) + find_package(ZLIB) + if(NOT ZLIB_FOUND) + message(FATAL_ERROR + "CMAKE_USE_SYSTEM_ZLIB is ON but a zlib is not found!") + endif() + set(CMAKE_ZLIB_INCLUDES ${ZLIB_INCLUDE_DIR}) + set(CMAKE_ZLIB_LIBRARIES ${ZLIB_LIBRARIES}) +else() + set(CMAKE_ZLIB_INCLUDES ${CMake_SOURCE_DIR}/Utilities) + set(CMAKE_ZLIB_LIBRARIES cmzlib) + set(WITHOUT_ZLIB_DLL "") + set(WITHOUT_ZLIB_DLL_WITH_LIB cmzlib) + set(ZLIB_DLL "") + set(ZLIB_DLL_WITH_LIB cmzlib) + set(ZLIB_WINAPI "") + set(ZLIB_WINAPI_COMPILED 0) + set(ZLIB_WINAPI_WITH_LIB cmzlib) + add_subdirectory(Utilities/cmzlib) + CMAKE_SET_TARGET_FOLDER(cmzlib "Utilities/3rdParty") +endif() + +#--------------------------------------------------------------------- +# Build Curl library for CTest. +if(CMAKE_USE_SYSTEM_CURL) + find_package(CURL) + if(NOT CURL_FOUND) + message(FATAL_ERROR + "CMAKE_USE_SYSTEM_CURL is ON but a curl is not found!") + endif() + set(CMAKE_CURL_INCLUDES ${CURL_INCLUDE_DIRS}) + set(CMAKE_CURL_LIBRARIES ${CURL_LIBRARIES}) +else() + set(CURL_SPECIAL_ZLIB_H ${CMAKE_ZLIB_HEADER}) + set(CURL_SPECIAL_LIBZ_INCLUDES ${CMAKE_ZLIB_INCLUDES}) + set(CURL_SPECIAL_LIBZ ${CMAKE_ZLIB_LIBRARIES}) + set(CMAKE_CURL_INCLUDES) + set(CMAKE_CURL_LIBRARIES cmcurl) + if(CMAKE_TESTS_CDASH_SERVER) + set(CMAKE_CURL_TEST_URL "${CMAKE_TESTS_CDASH_SERVER}/user.php") + endif() + set(_CMAKE_USE_OPENSSL_DEFAULT OFF) + if(NOT DEFINED CMAKE_USE_OPENSSL AND NOT WIN32 AND NOT APPLE + AND CMAKE_SYSTEM_NAME MATCHES "(Linux|FreeBSD)") + set(_CMAKE_USE_OPENSSL_DEFAULT ON) + endif() + option(CMAKE_USE_OPENSSL "Use OpenSSL." ${_CMAKE_USE_OPENSSL_DEFAULT}) + mark_as_advanced(CMAKE_USE_OPENSSL) + if(CMAKE_USE_OPENSSL) + set(CURL_CA_BUNDLE "" CACHE FILEPATH "Path to SSL CA Certificate Bundle") + set(CURL_CA_PATH "" CACHE PATH "Path to SSL CA Certificate Directory") + mark_as_advanced(CURL_CA_BUNDLE CURL_CA_PATH) + endif() + if(NOT CMAKE_USE_SYSTEM_NGHTTP2) + # Tell curl's FindNGHTTP2 module to use our library. + set(NGHTTP2_LIBRARY cmnghttp2) + set(NGHTTP2_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmnghttp2/lib/includes) + endif() + add_subdirectory(Utilities/cmcurl) + CMAKE_SET_TARGET_FOLDER(cmcurl "Utilities/3rdParty") + CMAKE_SET_TARGET_FOLDER(LIBCURL "Utilities/3rdParty") + if(NOT CMAKE_USE_SYSTEM_NGHTTP2) + # Configure after curl to re-use some check results. + add_subdirectory(Utilities/cmnghttp2) + CMAKE_SET_TARGET_FOLDER(cmnghttp2 "Utilities/3rdParty") + endif() +endif() + +#--------------------------------------------------------------------- +# Build expat library for CMake, CTest, and libarchive. +if(CMAKE_USE_SYSTEM_EXPAT) + find_package(EXPAT) + if(NOT EXPAT_FOUND) + message(FATAL_ERROR + "CMAKE_USE_SYSTEM_EXPAT is ON but a expat is not found!") + endif() + set(CMAKE_EXPAT_INCLUDES ${EXPAT_INCLUDE_DIRS}) + set(CMAKE_EXPAT_LIBRARIES ${EXPAT_LIBRARIES}) +else() + set(CMAKE_EXPAT_INCLUDES) + set(CMAKE_EXPAT_LIBRARIES cmexpat) + add_subdirectory(Utilities/cmexpat) + CMAKE_SET_TARGET_FOLDER(cmexpat "Utilities/3rdParty") +endif() + +#--------------------------------------------------------------------- +# Build or use system libbz2 for libarchive. +if(NOT CMAKE_USE_SYSTEM_LIBARCHIVE) + if(CMAKE_USE_SYSTEM_BZIP2) + find_package(BZip2) + else() + set(BZIP2_INCLUDE_DIR + "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmbzip2") + set(BZIP2_LIBRARIES cmbzip2) + set(BZIP2_NEED_PREFIX "") + set(USE_BZIP2_DLL "") + set(USE_BZIP2_DLL_WITH_LIB cmbzip2) + set(USE_BZIP2_STATIC "") + set(USE_BZIP2_STATIC_WITH_LIB cmbzip2) + add_subdirectory(Utilities/cmbzip2) + CMAKE_SET_TARGET_FOLDER(cmbzip2 "Utilities/3rdParty") + endif() +endif() + +#--------------------------------------------------------------------- +# Build or use system zstd for libarchive. +if(NOT CMAKE_USE_SYSTEM_LIBARCHIVE) + if(NOT CMAKE_USE_SYSTEM_ZSTD) + set(ZSTD_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmzstd") + set(ZSTD_LIBRARY cmzstd) + add_subdirectory(Utilities/cmzstd) + CMAKE_SET_TARGET_FOLDER(cmzstd "Utilities/3rdParty") + endif() +endif() + +#--------------------------------------------------------------------- +# Build or use system liblzma for libarchive. +if(NOT CMAKE_USE_SYSTEM_LIBARCHIVE) + if(CMAKE_USE_SYSTEM_LIBLZMA) + find_package(LibLZMA) + if(NOT LIBLZMA_FOUND) + message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBLZMA is ON but LibLZMA is not found!") + endif() + else() + add_subdirectory(Utilities/cmliblzma) + CMAKE_SET_TARGET_FOLDER(cmliblzma "Utilities/3rdParty") + set(LIBLZMA_HAS_AUTO_DECODER 1) + set(LIBLZMA_HAS_EASY_ENCODER 1) + set(LIBLZMA_HAS_LZMA_PRESET 1) + set(LIBLZMA_INCLUDE_DIR + "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmliblzma/liblzma/api") + set(LIBLZMA_LIBRARY cmliblzma) + set(HAVE_LZMA_STREAM_ENCODER_MT 1) + endif() +endif() + +#--------------------------------------------------------------------- +# Build or use system libarchive for CMake and CTest. +if(CMAKE_USE_SYSTEM_LIBARCHIVE) + find_package(LibArchive 3.3.3) + if(NOT LibArchive_FOUND) + message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBARCHIVE is ON but LibArchive is not found!") + endif() + set(CMAKE_TAR_INCLUDES ${LibArchive_INCLUDE_DIRS}) + set(CMAKE_TAR_LIBRARIES ${LibArchive_LIBRARIES}) +else() + set(EXPAT_INCLUDE_DIR ${CMAKE_EXPAT_INCLUDES}) + set(EXPAT_LIBRARY ${CMAKE_EXPAT_LIBRARIES}) + set(ZLIB_INCLUDE_DIR ${CMAKE_ZLIB_INCLUDES}) + set(ZLIB_LIBRARY ${CMAKE_ZLIB_LIBRARIES}) + add_compile_definitions(LIBARCHIVE_STATIC) + set(ENABLE_MBEDTLS OFF) + set(ENABLE_NETTLE OFF) + if(DEFINED CMAKE_USE_OPENSSL) + set(ENABLE_OPENSSL "${CMAKE_USE_OPENSSL}") + else() + set(ENABLE_OPENSSL OFF) + endif() + set(ENABLE_LIBB2 OFF) + set(ENABLE_LZ4 OFF) + set(ENABLE_LZO OFF) + set(ENABLE_LZMA ON) + set(ENABLE_ZSTD ON) + set(ENABLE_ZLIB ON) + set(ENABLE_BZip2 ON) + set(ENABLE_LIBXML2 OFF) + set(ENABLE_EXPAT OFF) + set(ENABLE_PCREPOSIX OFF) + set(ENABLE_LibGCC OFF) + set(ENABLE_CNG OFF) + set(ENABLE_TAR OFF) + set(ENABLE_TAR_SHARED OFF) + set(ENABLE_CPIO OFF) + set(ENABLE_CPIO_SHARED OFF) + set(ENABLE_CAT OFF) + set(ENABLE_CAT_SHARED OFF) + set(ENABLE_XATTR OFF) + set(ENABLE_ACL OFF) + set(ENABLE_ICONV OFF) + set(ENABLE_TEST OFF) + set(ENABLE_COVERAGE OFF) + set(ENABLE_INSTALL OFF) + set(POSIX_REGEX_LIB "" CACHE INTERNAL "libarchive: No POSIX regular expression support") + set(ENABLE_SAFESEH "" CACHE INTERNAL "libarchive: No /SAFESEH linker flag") + set(WINDOWS_VERSION "WIN7" CACHE INTERNAL "libarchive: Set Windows version to use (Windows only)") + add_subdirectory(Utilities/cmlibarchive) + CMAKE_SET_TARGET_FOLDER(cmlibarchive "Utilities/3rdParty") + set(CMAKE_TAR_LIBRARIES cmlibarchive ${BZIP2_LIBRARIES}) +endif() + +#--------------------------------------------------------------------- +# Build jsoncpp library. +if(CMAKE_USE_SYSTEM_JSONCPP) + find_package(JsonCpp 1.6.0) + if(NOT JsonCpp_FOUND) + message(FATAL_ERROR + "CMAKE_USE_SYSTEM_JSONCPP is ON but a JsonCpp is not found!") + endif() + if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|LCC|Clang") + set_property(TARGET JsonCpp::JsonCpp APPEND PROPERTY + INTERFACE_COMPILE_OPTIONS -Wno-deprecated-declarations) + endif() + set(CMAKE_JSONCPP_LIBRARIES JsonCpp::JsonCpp) +else() + set(CMAKE_JSONCPP_LIBRARIES cmjsoncpp) + add_subdirectory(Utilities/cmjsoncpp) + CMAKE_SET_TARGET_FOLDER(cmjsoncpp "Utilities/3rdParty") +endif() + +#--------------------------------------------------------------------- +# Build libuv library. +if(CMAKE_USE_SYSTEM_LIBUV) + if(WIN32) + find_package(LibUV 1.38.0) + else() + find_package(LibUV 1.28.0) + endif() + if(NOT LIBUV_FOUND) + message(FATAL_ERROR + "CMAKE_USE_SYSTEM_LIBUV is ON but a libuv is not found!") + endif() + set(CMAKE_LIBUV_LIBRARIES LibUV::LibUV) +else() + set(CMAKE_LIBUV_LIBRARIES cmlibuv) + add_subdirectory(Utilities/cmlibuv) + CMAKE_SET_TARGET_FOLDER(cmlibuv "Utilities/3rdParty") +endif() + +#--------------------------------------------------------------------- +# Use curses? +if(NOT DEFINED BUILD_CursesDialog) + if(UNIX) + include(${CMake_SOURCE_DIR}/Source/Checks/Curses.cmake) + set(BUILD_CursesDialog_DEFAULT "${CMakeCheckCurses_COMPILED}") + elseif(WIN32) + set(BUILD_CursesDialog_DEFAULT "OFF") + endif() + option(BUILD_CursesDialog "Build the CMake Curses Dialog ccmake" "${BUILD_CursesDialog_DEFAULT}") +endif() +if(BUILD_CursesDialog) + if(UNIX) + set(CURSES_NEED_NCURSES TRUE) + find_package(Curses) + if(NOT CURSES_FOUND) + message(WARNING + "'ccmake' will not be built because Curses was not found.\n" + "Turn off BUILD_CursesDialog to suppress this message." + ) + set(BUILD_CursesDialog 0) + endif() + elseif(WIN32) + # FIXME: Add support for system-provided pdcurses. + add_subdirectory(Utilities/cmpdcurses) + set(CURSES_LIBRARY cmpdcurses) + set(CURSES_INCLUDE_PATH "") # cmpdcurses has usage requirements + set(CMAKE_USE_SYSTEM_FORM 0) + set(HAVE_CURSES_USE_DEFAULT_COLORS 1) + endif() +endif() +if(BUILD_CursesDialog) + if(NOT CMAKE_USE_SYSTEM_FORM) + add_subdirectory(Source/CursesDialog/form) + elseif(NOT CURSES_FORM_LIBRARY) + message(FATAL_ERROR "CMAKE_USE_SYSTEM_FORM in ON but CURSES_FORM_LIBRARY is not set!") + endif() +endif() -- cgit v0.12 From 14b94f9bf2e8ada7508ae0a248f376746c18d29c Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 08:58:24 +0400 Subject: =?UTF-8?q?Build:=20Use=20`string(APPEND=E2=80=A6)`=20in=20the=20r?= =?UTF-8?q?oot=20`CMakeLists.txt`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ae8d05a..a4f533d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -420,10 +420,9 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE) set(CMAKE_BUNDLE_LOCATION "${CMAKE_INSTALL_PREFIX}") # make sure CMAKE_INSTALL_PREFIX ends in / if(NOT CMAKE_INSTALL_PREFIX MATCHES "/$") - set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/") + string(APPEND CMAKE_INSTALL_PREFIX "/") endif() - set(CMAKE_INSTALL_PREFIX - "${CMAKE_INSTALL_PREFIX}CMake.app/Contents") + string(APPEND CMAKE_INSTALL_PREFIX "CMake.app/Contents") endif() endif() @@ -467,7 +466,7 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE) foreach(FLAG_LANG IN ITEMS C CXX) foreach(FLAG IN LISTS ${FLAG_LANG}_FLAGS_LIST) if(NOT " ${CMAKE_${FLAG_LANG}_FLAGS} " MATCHES " ${FLAG} ") - set(CMAKE_${FLAG_LANG}_FLAGS "${CMAKE_${FLAG_LANG}_FLAGS} ${FLAG}") + string(APPEND CMAKE_${FLAG_LANG}_FLAGS " ${FLAG}") endif() endforeach() endforeach() -- cgit v0.12 From 2be5a7de4ea987649dfc1ac669928fecf2613046 Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 09:02:56 +0400 Subject: Build: Use imported target `ZLIB::ZLIB` instead of variables --- Source/CMakeLists.txt | 3 +-- Source/Modules/CMakeBuildUtilities.cmake | 18 ++++++++---------- Utilities/cmcurl/CMakeLists.txt | 17 +++-------------- Utilities/cmcurl/lib/content_encoding.c | 2 +- Utilities/cmcurl/lib/version.c | 2 +- Utilities/cmlibarchive/CMakeLists.txt | 2 ++ 6 files changed, 16 insertions(+), 28 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 9357fdf..3edaabb 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -743,7 +743,6 @@ target_include_directories( "${CMake_BINARY_DIR}/Source" "${CMake_SOURCE_DIR}/Source" "${CMake_SOURCE_DIR}/Source/LexerParser" - ${CMAKE_ZLIB_INCLUDES} ${CMAKE_EXPAT_INCLUDES} ${CMAKE_TAR_INCLUDES} ${CMake_HAIKU_INCLUDE_DIRS} @@ -753,8 +752,8 @@ target_link_libraries( PUBLIC cmstd cmsys + ZLIB::ZLIB ${CMAKE_EXPAT_LIBRARIES} - ${CMAKE_ZLIB_LIBRARIES} ${CMAKE_TAR_LIBRARIES} ${CMAKE_CURL_LIBRARIES} ${CMAKE_JSONCPP_LIBRARIES} diff --git a/Source/Modules/CMakeBuildUtilities.cmake b/Source/Modules/CMakeBuildUtilities.cmake index 4823adf..f217f9b 100644 --- a/Source/Modules/CMakeBuildUtilities.cmake +++ b/Source/Modules/CMakeBuildUtilities.cmake @@ -114,18 +114,20 @@ endif() #--------------------------------------------------------------------- # Build zlib library for Curl, CMake, and CTest. -set(CMAKE_ZLIB_HEADER "cm_zlib.h") if(CMAKE_USE_SYSTEM_ZLIB) find_package(ZLIB) if(NOT ZLIB_FOUND) message(FATAL_ERROR "CMAKE_USE_SYSTEM_ZLIB is ON but a zlib is not found!") endif() - set(CMAKE_ZLIB_INCLUDES ${ZLIB_INCLUDE_DIR}) - set(CMAKE_ZLIB_LIBRARIES ${ZLIB_LIBRARIES}) else() - set(CMAKE_ZLIB_INCLUDES ${CMake_SOURCE_DIR}/Utilities) - set(CMAKE_ZLIB_LIBRARIES cmzlib) + if(NOT POLICY CMP0102) # CMake < 3.17 + # Store in cache to protect from mark_as_advanced. + set(ZLIB_INCLUDE_DIR ${CMake_SOURCE_DIR}/Utilities CACHE PATH "") + else() + set(ZLIB_INCLUDE_DIR ${CMake_SOURCE_DIR}/Utilities) + endif() + set(ZLIB_LIBRARY cmzlib) set(WITHOUT_ZLIB_DLL "") set(WITHOUT_ZLIB_DLL_WITH_LIB cmzlib) set(ZLIB_DLL "") @@ -134,6 +136,7 @@ else() set(ZLIB_WINAPI_COMPILED 0) set(ZLIB_WINAPI_WITH_LIB cmzlib) add_subdirectory(Utilities/cmzlib) + add_library(ZLIB::ZLIB ALIAS cmzlib) CMAKE_SET_TARGET_FOLDER(cmzlib "Utilities/3rdParty") endif() @@ -148,9 +151,6 @@ if(CMAKE_USE_SYSTEM_CURL) set(CMAKE_CURL_INCLUDES ${CURL_INCLUDE_DIRS}) set(CMAKE_CURL_LIBRARIES ${CURL_LIBRARIES}) else() - set(CURL_SPECIAL_ZLIB_H ${CMAKE_ZLIB_HEADER}) - set(CURL_SPECIAL_LIBZ_INCLUDES ${CMAKE_ZLIB_INCLUDES}) - set(CURL_SPECIAL_LIBZ ${CMAKE_ZLIB_LIBRARIES}) set(CMAKE_CURL_INCLUDES) set(CMAKE_CURL_LIBRARIES cmcurl) if(CMAKE_TESTS_CDASH_SERVER) @@ -263,8 +263,6 @@ if(CMAKE_USE_SYSTEM_LIBARCHIVE) else() set(EXPAT_INCLUDE_DIR ${CMAKE_EXPAT_INCLUDES}) set(EXPAT_LIBRARY ${CMAKE_EXPAT_LIBRARIES}) - set(ZLIB_INCLUDE_DIR ${CMAKE_ZLIB_INCLUDES}) - set(ZLIB_LIBRARY ${CMAKE_ZLIB_LIBRARIES}) add_compile_definitions(LIBARCHIVE_STATIC) set(ENABLE_MBEDTLS OFF) set(ENABLE_NETTLE OFF) diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt index b8cf412..9b468c3 100644 --- a/Utilities/cmcurl/CMakeLists.txt +++ b/Utilities/cmcurl/CMakeLists.txt @@ -852,11 +852,11 @@ endif() # Check for symbol dlopen (same as HAVE_LIBDL) check_library_exists("${CURL_LIBS}" dlopen "" HAVE_DLOPEN) -if(0) # This code not needed for building within CMake. set(HAVE_LIBZ OFF) set(HAVE_ZLIB_H OFF) set(USE_ZLIB OFF) -optional_dependency(ZLIB) +#optional_dependency(ZLIB) +find_package(ZLIB) if(ZLIB_FOUND) set(HAVE_ZLIB_H ON) set(HAVE_LIBZ ON) @@ -870,19 +870,8 @@ if(ZLIB_FOUND) else() list(APPEND CURL_LIBS ${ZLIB_LIBRARIES}) include_directories(${ZLIB_INCLUDE_DIRS}) + list(APPEND CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIRS}) endif() - list(APPEND CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIRS}) -endif() -endif() - -#----------------------------------------------------------------------------- -# CMake-specific curl code. - -if(CURL_SPECIAL_LIBZ) - set(CURL_LIBS ${CURL_LIBS} "${CURL_SPECIAL_LIBZ}") - include_directories(${CURL_SPECIAL_LIBZ_INCLUDES}) - set(HAVE_LIBZ 0) - set(HAVE_ZLIB_H 0) endif() option(CURL_BROTLI "Set to ON to enable building curl with brotli support." OFF) diff --git a/Utilities/cmcurl/lib/content_encoding.c b/Utilities/cmcurl/lib/content_encoding.c index c03637a..4c723c3 100644 --- a/Utilities/cmcurl/lib/content_encoding.c +++ b/Utilities/cmcurl/lib/content_encoding.c @@ -27,7 +27,7 @@ #include #ifdef HAVE_ZLIB_H -#include +#include #endif #ifdef HAVE_BROTLI diff --git a/Utilities/cmcurl/lib/version.c b/Utilities/cmcurl/lib/version.c index e37253d..5e3e428 100644 --- a/Utilities/cmcurl/lib/version.c +++ b/Utilities/cmcurl/lib/version.c @@ -51,7 +51,7 @@ #endif #ifdef HAVE_ZLIB_H -#include +#include #endif #ifdef HAVE_BROTLI diff --git a/Utilities/cmlibarchive/CMakeLists.txt b/Utilities/cmlibarchive/CMakeLists.txt index eea472f..b38e653 100644 --- a/Utilities/cmlibarchive/CMakeLists.txt +++ b/Utilities/cmlibarchive/CMakeLists.txt @@ -442,6 +442,8 @@ SET(ADDITIONAL_LIBS "") # IF(ENABLE_ZLIB) FIND_PACKAGE(ZLIB) + SET(ZLIB_INCLUDE_DIR "") + SET(ZLIB_LIBRARIES ZLIB::ZLIB) ELSE() SET(ZLIB_FOUND FALSE) # Override cached value ENDIF() -- cgit v0.12 From 9cdf5a67790ef78292366268af0a3de4b5cc3892 Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 09:05:53 +0400 Subject: Build: Use imported target `EXPAT::EXPAT` instead of variables --- Source/CMakeLists.txt | 3 +-- Source/Modules/CMakeBuildUtilities.cmake | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 3edaabb..93b3f0c 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -743,7 +743,6 @@ target_include_directories( "${CMake_BINARY_DIR}/Source" "${CMake_SOURCE_DIR}/Source" "${CMake_SOURCE_DIR}/Source/LexerParser" - ${CMAKE_EXPAT_INCLUDES} ${CMAKE_TAR_INCLUDES} ${CMake_HAIKU_INCLUDE_DIRS} ) @@ -752,8 +751,8 @@ target_link_libraries( PUBLIC cmstd cmsys + EXPAT::EXPAT ZLIB::ZLIB - ${CMAKE_EXPAT_LIBRARIES} ${CMAKE_TAR_LIBRARIES} ${CMAKE_CURL_LIBRARIES} ${CMAKE_JSONCPP_LIBRARIES} diff --git a/Source/Modules/CMakeBuildUtilities.cmake b/Source/Modules/CMakeBuildUtilities.cmake index f217f9b..dad4bc1 100644 --- a/Source/Modules/CMakeBuildUtilities.cmake +++ b/Source/Modules/CMakeBuildUtilities.cmake @@ -197,6 +197,7 @@ else() set(CMAKE_EXPAT_INCLUDES) set(CMAKE_EXPAT_LIBRARIES cmexpat) add_subdirectory(Utilities/cmexpat) + add_library(EXPAT::EXPAT ALIAS cmexpat) CMAKE_SET_TARGET_FOLDER(cmexpat "Utilities/3rdParty") endif() -- cgit v0.12 From 1f5d9c5299bb7add5a7afcc1d054fd4259c04b89 Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 09:13:32 +0400 Subject: Build: Use imported target `LibArchive::LibArchive` instead of variables --- Modules/FindLibArchive.cmake | 3 +++ Source/CMakeLists.txt | 3 +-- Source/Modules/CMakeBuildUtilities.cmake | 13 +++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Modules/FindLibArchive.cmake b/Modules/FindLibArchive.cmake index 08078a2..9d3ac13 100644 --- a/Modules/FindLibArchive.cmake +++ b/Modules/FindLibArchive.cmake @@ -26,6 +26,9 @@ The module defines the following ``IMPORTED`` targets: .. versionadded:: 3.6 Support for new libarchive 3.2 version string format. +.. versionadded:: 3.17 + Provides an imported target. + #]=======================================================================] find_path(LibArchive_INCLUDE_DIR diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 93b3f0c..b1d8cb7 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -743,7 +743,6 @@ target_include_directories( "${CMake_BINARY_DIR}/Source" "${CMake_SOURCE_DIR}/Source" "${CMake_SOURCE_DIR}/Source/LexerParser" - ${CMAKE_TAR_INCLUDES} ${CMake_HAIKU_INCLUDE_DIRS} ) target_link_libraries( @@ -752,8 +751,8 @@ target_link_libraries( cmstd cmsys EXPAT::EXPAT + LibArchive::LibArchive ZLIB::ZLIB - ${CMAKE_TAR_LIBRARIES} ${CMAKE_CURL_LIBRARIES} ${CMAKE_JSONCPP_LIBRARIES} ${CMAKE_LIBUV_LIBRARIES} diff --git a/Source/Modules/CMakeBuildUtilities.cmake b/Source/Modules/CMakeBuildUtilities.cmake index dad4bc1..157367f 100644 --- a/Source/Modules/CMakeBuildUtilities.cmake +++ b/Source/Modules/CMakeBuildUtilities.cmake @@ -259,12 +259,16 @@ if(CMAKE_USE_SYSTEM_LIBARCHIVE) if(NOT LibArchive_FOUND) message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBARCHIVE is ON but LibArchive is not found!") endif() - set(CMAKE_TAR_INCLUDES ${LibArchive_INCLUDE_DIRS}) - set(CMAKE_TAR_LIBRARIES ${LibArchive_LIBRARIES}) + # NOTE `FindLibArchive` got imported targets support since 3.17 + if (NOT TARGET LibArchive::LibArchive) + add_library(LibArchive::LibArchive UNKNOWN IMPORTED) + set_target_properties(LibArchive::LibArchive PROPERTIES + IMPORTED_LOCATION "${LibArchive_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${LibArchive_INCLUDE_DIRS}") + endif () else() set(EXPAT_INCLUDE_DIR ${CMAKE_EXPAT_INCLUDES}) set(EXPAT_LIBRARY ${CMAKE_EXPAT_LIBRARIES}) - add_compile_definitions(LIBARCHIVE_STATIC) set(ENABLE_MBEDTLS OFF) set(ENABLE_NETTLE OFF) if(DEFINED CMAKE_USE_OPENSSL) @@ -300,8 +304,9 @@ else() set(ENABLE_SAFESEH "" CACHE INTERNAL "libarchive: No /SAFESEH linker flag") set(WINDOWS_VERSION "WIN7" CACHE INTERNAL "libarchive: Set Windows version to use (Windows only)") add_subdirectory(Utilities/cmlibarchive) + add_library(LibArchive::LibArchive ALIAS cmlibarchive) + target_compile_definitions(cmlibarchive INTERFACE LIBARCHIVE_STATIC) CMAKE_SET_TARGET_FOLDER(cmlibarchive "Utilities/3rdParty") - set(CMAKE_TAR_LIBRARIES cmlibarchive ${BZIP2_LIBRARIES}) endif() #--------------------------------------------------------------------- -- cgit v0.12 From ac76c53d33e16a159d3152105e6f99f241769691 Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 09:21:01 +0400 Subject: Build: Use imported target `CURL::libcurl` instead of variables --- Source/CMakeLists.txt | 5 ++--- Source/Modules/CMakeBuildUtilities.cmake | 5 +---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index b1d8cb7..c8465a5 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -750,10 +750,10 @@ target_link_libraries( PUBLIC cmstd cmsys + CURL::libcurl EXPAT::EXPAT LibArchive::LibArchive ZLIB::ZLIB - ${CMAKE_CURL_LIBRARIES} ${CMAKE_JSONCPP_LIBRARIES} ${CMAKE_LIBUV_LIBRARIES} ${CMAKE_LIBRHASH_LIBRARIES} @@ -1002,9 +1002,8 @@ target_include_directories( CTestLib PUBLIC "${CMake_SOURCE_DIR}/Source/CTest" - ${CMAKE_CURL_INCLUDES} ) -target_link_libraries(CTestLib PUBLIC CMakeLib ${CMAKE_CURL_LIBRARIES}) +target_link_libraries(CTestLib PUBLIC CMakeLib) # # Build CPackLib diff --git a/Source/Modules/CMakeBuildUtilities.cmake b/Source/Modules/CMakeBuildUtilities.cmake index 157367f..51811d6 100644 --- a/Source/Modules/CMakeBuildUtilities.cmake +++ b/Source/Modules/CMakeBuildUtilities.cmake @@ -148,11 +148,7 @@ if(CMAKE_USE_SYSTEM_CURL) message(FATAL_ERROR "CMAKE_USE_SYSTEM_CURL is ON but a curl is not found!") endif() - set(CMAKE_CURL_INCLUDES ${CURL_INCLUDE_DIRS}) - set(CMAKE_CURL_LIBRARIES ${CURL_LIBRARIES}) else() - set(CMAKE_CURL_INCLUDES) - set(CMAKE_CURL_LIBRARIES cmcurl) if(CMAKE_TESTS_CDASH_SERVER) set(CMAKE_CURL_TEST_URL "${CMAKE_TESTS_CDASH_SERVER}/user.php") endif() @@ -174,6 +170,7 @@ else() set(NGHTTP2_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmnghttp2/lib/includes) endif() add_subdirectory(Utilities/cmcurl) + add_library(CURL::libcurl ALIAS cmcurl) CMAKE_SET_TARGET_FOLDER(cmcurl "Utilities/3rdParty") CMAKE_SET_TARGET_FOLDER(LIBCURL "Utilities/3rdParty") if(NOT CMAKE_USE_SYSTEM_NGHTTP2) -- cgit v0.12 From ddac6dcbe8029a5850377ffb9aee088d9493e2ce Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 09:22:59 +0400 Subject: Build: Use imported target `JsonCpp::JsonCpp` instead of variables --- Source/CMakeLists.txt | 2 +- Source/Modules/CMakeBuildUtilities.cmake | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index c8465a5..31d514d 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -754,7 +754,7 @@ target_link_libraries( EXPAT::EXPAT LibArchive::LibArchive ZLIB::ZLIB - ${CMAKE_JSONCPP_LIBRARIES} + JsonCpp::JsonCpp ${CMAKE_LIBUV_LIBRARIES} ${CMAKE_LIBRHASH_LIBRARIES} ${CMake_KWIML_LIBRARIES} diff --git a/Source/Modules/CMakeBuildUtilities.cmake b/Source/Modules/CMakeBuildUtilities.cmake index 51811d6..b17c7ce 100644 --- a/Source/Modules/CMakeBuildUtilities.cmake +++ b/Source/Modules/CMakeBuildUtilities.cmake @@ -318,10 +318,9 @@ if(CMAKE_USE_SYSTEM_JSONCPP) set_property(TARGET JsonCpp::JsonCpp APPEND PROPERTY INTERFACE_COMPILE_OPTIONS -Wno-deprecated-declarations) endif() - set(CMAKE_JSONCPP_LIBRARIES JsonCpp::JsonCpp) else() - set(CMAKE_JSONCPP_LIBRARIES cmjsoncpp) add_subdirectory(Utilities/cmjsoncpp) + add_library(JsonCpp::JsonCpp ALIAS cmjsoncpp) CMAKE_SET_TARGET_FOLDER(cmjsoncpp "Utilities/3rdParty") endif() -- cgit v0.12 From 08be01a1813c497c03240e302efb900e2663532b Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 09:23:57 +0400 Subject: Build: Use imported target `LibUV::LibUV` instead of variables --- Source/CMakeLists.txt | 2 +- Source/Modules/CMakeBuildUtilities.cmake | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 31d514d..31dbd5d 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -755,7 +755,7 @@ target_link_libraries( LibArchive::LibArchive ZLIB::ZLIB JsonCpp::JsonCpp - ${CMAKE_LIBUV_LIBRARIES} + LibUV::LibUV ${CMAKE_LIBRHASH_LIBRARIES} ${CMake_KWIML_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} diff --git a/Source/Modules/CMakeBuildUtilities.cmake b/Source/Modules/CMakeBuildUtilities.cmake index b17c7ce..71dd37f 100644 --- a/Source/Modules/CMakeBuildUtilities.cmake +++ b/Source/Modules/CMakeBuildUtilities.cmake @@ -336,10 +336,9 @@ if(CMAKE_USE_SYSTEM_LIBUV) message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBUV is ON but a libuv is not found!") endif() - set(CMAKE_LIBUV_LIBRARIES LibUV::LibUV) else() - set(CMAKE_LIBUV_LIBRARIES cmlibuv) add_subdirectory(Utilities/cmlibuv) + add_library(LibUV::LibUV ALIAS cmlibuv) CMAKE_SET_TARGET_FOLDER(cmlibuv "Utilities/3rdParty") endif() -- cgit v0.12 From eeebf31e54a04eee7a2a91bf80fce5a8fbae7e67 Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 09:26:35 +0400 Subject: Build: Use imported target `LibRHash::LibRHash` instead of variables --- Source/CMakeLists.txt | 2 +- Source/Modules/CMakeBuildUtilities.cmake | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 31dbd5d..2c5af7b 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -756,7 +756,7 @@ target_link_libraries( ZLIB::ZLIB JsonCpp::JsonCpp LibUV::LibUV - ${CMAKE_LIBRHASH_LIBRARIES} + LibRHash::LibRHash ${CMake_KWIML_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ) diff --git a/Source/Modules/CMakeBuildUtilities.cmake b/Source/Modules/CMakeBuildUtilities.cmake index 71dd37f..e420c67 100644 --- a/Source/Modules/CMakeBuildUtilities.cmake +++ b/Source/Modules/CMakeBuildUtilities.cmake @@ -105,10 +105,9 @@ if(CMAKE_USE_SYSTEM_LIBRHASH) message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBRHASH is ON but LibRHash is not found!") endif() - set(CMAKE_LIBRHASH_LIBRARIES LibRHash::LibRHash) else() - set(CMAKE_LIBRHASH_LIBRARIES cmlibrhash) add_subdirectory(Utilities/cmlibrhash) + add_library(LibRHash::LibRHash ALIAS cmlibrhash) CMAKE_SET_TARGET_FOLDER(cmlibrhash "Utilities/3rdParty") endif() -- cgit v0.12 From df8ad72ffa7c193638a7a086284bc455cccc5b5f Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 09:40:57 +0400 Subject: Build: Use imported target `kwiml::kwiml` instead of variables --- Source/CMakeLists.txt | 2 +- Source/Modules/CMakeBuildUtilities.cmake | 2 -- Utilities/cmjsoncpp/CMakeLists.txt | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 2c5af7b..cea16ec 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -757,7 +757,7 @@ target_link_libraries( JsonCpp::JsonCpp LibUV::LibUV LibRHash::LibRHash - ${CMake_KWIML_LIBRARIES} + $ ${CMAKE_THREAD_LIBS_INIT} ) diff --git a/Source/Modules/CMakeBuildUtilities.cmake b/Source/Modules/CMakeBuildUtilities.cmake index e420c67..5cfb0e7 100644 --- a/Source/Modules/CMakeBuildUtilities.cmake +++ b/Source/Modules/CMakeBuildUtilities.cmake @@ -90,9 +90,7 @@ if(CMAKE_USE_SYSTEM_KWIML) if(NOT KWIML_FOUND) message(FATAL_ERROR "CMAKE_USE_SYSTEM_KWIML is ON but KWIML is not found!") endif() - set(CMake_KWIML_LIBRARIES kwiml::kwiml) else() - set(CMake_KWIML_LIBRARIES "") if(BUILD_TESTING) set(KWIML_TEST_ENABLE 1) endif() diff --git a/Utilities/cmjsoncpp/CMakeLists.txt b/Utilities/cmjsoncpp/CMakeLists.txt index c384f4e..09579d2 100644 --- a/Utilities/cmjsoncpp/CMakeLists.txt +++ b/Utilities/cmjsoncpp/CMakeLists.txt @@ -21,5 +21,5 @@ include_directories( ) add_library(cmjsoncpp ${JSONCPP_SOURCES}) -target_link_libraries(cmjsoncpp ${CMake_KWIML_LIBRARIES}) +target_link_libraries(cmjsoncpp $) set_property(TARGET cmjsoncpp PROPERTY CXX_INCLUDE_WHAT_YOU_USE "") -- cgit v0.12 From aa7290e8dc5c9d8073c150e5d351b21fa43847bb Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 09:46:27 +0400 Subject: Build: Use imported target `Threads::Threads` instead of variable --- Source/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index cea16ec..e4286b9 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -758,7 +758,7 @@ target_link_libraries( LibUV::LibUV LibRHash::LibRHash $ - ${CMAKE_THREAD_LIBS_INIT} + Threads::Threads ) # Check if we can build the Mach-O parser. -- cgit v0.12 From e6fb5a1febde8a30e578f08e04887c6e4e5511b4 Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 09:52:41 +0400 Subject: Build: Sort linked libraries list of `CMakeLib` --- Source/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index e4286b9..fe04641 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -752,13 +752,13 @@ target_link_libraries( cmsys CURL::libcurl EXPAT::EXPAT - LibArchive::LibArchive - ZLIB::ZLIB JsonCpp::JsonCpp - LibUV::LibUV - LibRHash::LibRHash $ + LibArchive::LibArchive + LibRHash::LibRHash + LibUV::LibUV Threads::Threads + ZLIB::ZLIB ) # Check if we can build the Mach-O parser. -- cgit v0.12 From 9629be8080d054ab44603802923a3ce72620f864 Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 21 Aug 2022 10:01:34 +0400 Subject: Build: Use `CMAKE_CURRENT_XXX_DIR` instead of top dirs --- Source/CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index fe04641..32bd341 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -740,9 +740,9 @@ target_include_directories( CMakeLib PUBLIC # add the include path to find the .h - "${CMake_BINARY_DIR}/Source" - "${CMake_SOURCE_DIR}/Source" - "${CMake_SOURCE_DIR}/Source/LexerParser" + "${CMAKE_CURRENT_BINARY_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}/LexerParser" ${CMake_HAIKU_INCLUDE_DIRS} ) target_link_libraries( @@ -1001,7 +1001,7 @@ add_library( target_include_directories( CTestLib PUBLIC - "${CMake_SOURCE_DIR}/Source/CTest" + "${CMAKE_CURRENT_SOURCE_DIR}/CTest" ) target_link_libraries(CTestLib PUBLIC CMakeLib) @@ -1175,8 +1175,8 @@ if(BUILD_QtDialog) add_subdirectory(QtDialog) endif() -include(${CMake_BINARY_DIR}/Source/LocalUserOptions.cmake OPTIONAL) -include(${CMake_SOURCE_DIR}/Source/LocalUserOptions.cmake OPTIONAL) +include(${CMAKE_CURRENT_BINARY_DIR}/LocalUserOptions.cmake OPTIONAL) +include(${CMAKE_CURRENT_SOURCE_DIR}/LocalUserOptions.cmake OPTIONAL) if(WIN32) # Compute the binary version that appears in the RC file. Version -- cgit v0.12