diff options
author | Juan Ramos <juan@lunarg.com> | 2022-11-11 02:46:39 +0300 |
---|---|---|
committer | Juan Ramos <114601453+juan-lunarg@users.noreply.github.com> | 2022-11-11 03:16:53 +0300 |
commit | f18d3e3c5db1060dc7cb3e7836ab3c6f49d46ae4 (patch) | |
tree | 6cfc5f05cb155727e809b9aa01fa2e6b0f1b2369 | |
parent | ff7996f13644de8b212266f7e9e8708cccd03734 (diff) |
cmake: CMake cleanup
- Use idiom for CMAKE_MODULE_PATH
- find_package(PkgConfig) instead of include(FindPkgConfig)
- Remove CMake 2.X code workaround
- Use CMAKE_CURRENT_BINARY_DIR instead of CMAKE_BINARY_DIR
- CMakeParseArguments is now part of the language
-rw-r--r-- | BUILD.md | 4 | ||||
-rw-r--r-- | CMakeLists.txt | 16 | ||||
-rw-r--r-- | loader/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/framework/CMakeLists.txt | 3 |
4 files changed, 9 insertions, 16 deletions
@@ -390,8 +390,8 @@ the primary build artifacts to a specific location using a "bin, include, lib" style directory structure. This may be useful for collecting the artifacts and providing them to another project that is dependent on them. -The default location is `$CMAKE_BINARY_DIR\install`, but can be changed with -the `CMAKE_INSTALL_PREFIX` variable when first generating the project build +The default location is `$CMAKE_CURRENT_BINARY_DIR\install`, but can be changed +with the `CMAKE_INSTALL_PREFIX` variable when first generating the project build files with CMake. You can build the install target from the command line with: diff --git a/CMakeLists.txt b/CMakeLists.txt index cef78f06c..e71de78f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,8 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # ~~~ - cmake_minimum_required(VERSION 3.10.2) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") # If we are building in Visual Studio 2015 and with a CMake version 3.19 or greater, we need to set this variable # so that CMake will choose a Windows SDK version higher than 10.0.14393.0, as dxgi1_6.h is only found in Windows SDK @@ -49,7 +49,7 @@ if (UPDATE_DEPS) endif() message("********************************************************************************") - message("* NOTE: Adding target vl_update_deps to run as needed for updating *") + message("* NOTE: Adding target vl_update_deps to run as needed for updating *") message("* dependencies. *") message("********************************************************************************") @@ -83,7 +83,6 @@ if (VULKAN_HEADERS_INSTALL_DIR) list(APPEND CMAKE_PREFIX_PATH ${VULKAN_HEADERS_INSTALL_DIR}) endif() -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") find_package(PythonInterp 3 QUIET) set(THREADS_PREFER_PTHREAD_FLAG ON) @@ -115,12 +114,7 @@ find_package(VulkanHeaders REQUIRED CONFIG QUIET) include(GNUInstallDirs) if(UNIX AND NOT APPLE) # i.e.: Linux - include(FindPkgConfig) -endif() - -if(APPLE) - # CMake versions 3 or later need CMAKE_MACOSX_RPATH defined. This avoids the CMP0042 policy message. - set(CMAKE_MACOSX_RPATH 1) + find_package(PkgConfig) endif() set(GIT_BRANCH_NAME "--unknown--") @@ -147,7 +141,7 @@ endif() if(WIN32 AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) # Windows: if install locations not set by user, set install prefix to "<build_dir>\install". - set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "default install path" FORCE) + set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/install" CACHE PATH "default install path" FORCE) endif() # Enable IDE GUI folders. "Helper targets" that don't have interesting source code should set their FOLDER property to this @@ -464,7 +458,7 @@ if(BUILD_TESTS) endif() if (BUILD_TESTS) - add_subdirectory(tests ${CMAKE_BINARY_DIR}/tests) + add_subdirectory(tests) endif() endif() diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt index 17c0d6386..2eb704fde 100644 --- a/loader/CMakeLists.txt +++ b/loader/CMakeLists.txt @@ -381,7 +381,7 @@ if (TARGET asm_offset) endif() # Generate pkg-config file. -include(FindPkgConfig QUIET) +find_package(PkgConfig QUIET) if(PKG_CONFIG_FOUND) set(VK_API_VERSION "${LOADER_GENERATED_HEADER_VERSION}") set(PRIVATE_LIBS "") diff --git a/tests/framework/CMakeLists.txt b/tests/framework/CMakeLists.txt index b3d46f5bc..c04ebae89 100644 --- a/tests/framework/CMakeLists.txt +++ b/tests/framework/CMakeLists.txt @@ -51,7 +51,6 @@ if (MSVC) target_compile_options(testing_framework_util PUBLIC /wd4458) endif() -include(CMakeParseArguments) function(AddSharedLibrary LIBRARY_NAME) set(singleValueArgs DEF_FILE) set(multiValueArgs SOURCES DEFINITIONS) @@ -96,7 +95,7 @@ add_dependencies (testing_framework_util generate_framework_config) add_library(testing_dependencies STATIC test_environment.cpp test_environment.h) target_link_libraries(testing_dependencies PUBLIC gtest Vulkan::Headers testing_framework_util shim-library) -target_include_directories(testing_dependencies PUBLIC ${CMAKE_BINARY_DIR}/tests/framework) +target_include_directories(testing_dependencies PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) target_compile_definitions(testing_dependencies PUBLIC "GTEST_LINKED_AS_SHARED_LIBRARY=1") set_target_properties(testing_dependencies ${LOADER_STANDARD_CXX_PROPERTIES}) if (APPLE AND BUILD_STATIC_LOADER) |