mirror of
https://github.com/cpm-cmake/CPM.cmake.git
synced 2025-11-18 07:07:47 -05:00
add support for SOURCE_DIR argument (#97)
* add support for SOURCE_DIR argument * simplify code * add test * update comment
This commit is contained in:
19
test/unit/source_dir.cmake
Normal file
19
test/unit/source_dir.cmake
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
include(${CPM_PATH}/testing.cmake)
|
||||
|
||||
set(TEST_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/source_dir)
|
||||
|
||||
configure_package_config_file(
|
||||
"${CMAKE_CURRENT_LIST_DIR}/source_dir/CMakeLists.txt.in"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/source_dir/CMakeLists.txt"
|
||||
INSTALL_DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/junk
|
||||
)
|
||||
|
||||
execute_process(
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} "-H${CMAKE_CURRENT_LIST_DIR}/source_dir" "-B${TEST_BUILD_DIR}"
|
||||
RESULT_VARIABLE ret
|
||||
)
|
||||
|
||||
ASSERT_EQUAL(${ret} "0")
|
||||
1
test/unit/source_dir/.gitignore
vendored
Normal file
1
test/unit/source_dir/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/CMakeLists.txt
|
||||
20
test/unit/source_dir/CMakeLists.txt.in
Normal file
20
test/unit/source_dir/CMakeLists.txt.in
Normal file
@@ -0,0 +1,20 @@
|
||||
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
|
||||
|
||||
project(CPMExampleCatch2)
|
||||
|
||||
# ---- Options ----
|
||||
|
||||
option(ENABLE_TEST_COVERAGE "Enable test coverage" OFF)
|
||||
|
||||
# ---- Dependencies ----
|
||||
|
||||
include(@CPM_PATH@/CPM.cmake)
|
||||
|
||||
CPMAddPackage(
|
||||
NAME Dependency
|
||||
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/dependency
|
||||
)
|
||||
|
||||
# ---- Call dependency method to validate correct addition of directory ----
|
||||
|
||||
dependency_function()
|
||||
4
test/unit/source_dir/dependency/CMakeLists.txt
Normal file
4
test/unit/source_dir/dependency/CMakeLists.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
function(dependency_function)
|
||||
message("called external method")
|
||||
endfunction()
|
||||
Reference in New Issue
Block a user