Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
c67033a9
Commit
c67033a9
authored
Jun 25, 2017
by
Dean Moldovan
Browse files
Move test_cmake_build target code into its subdirectory
parent
0bc272b2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
56 deletions
+59
-56
tests/CMakeLists.txt
tests/CMakeLists.txt
+1
-56
tests/test_cmake_build/CMakeLists.txt
tests/test_cmake_build/CMakeLists.txt
+58
-0
No files found.
tests/CMakeLists.txt
View file @
c67033a9
...
...
@@ -198,59 +198,4 @@ add_custom_command(TARGET pybind11_tests POST_BUILD
add_subdirectory
(
test_embed
)
# Test CMake build using functions and targets from subdirectory or installed location
add_custom_target
(
test_cmake_build
)
if
(
NOT CMAKE_VERSION VERSION_LESS 3.1
)
# 3.0 needed for interface library for subdirectory_target/installed_target
# 3.1 needed for cmake -E env for testing
include
(
CMakeParseArguments
)
function
(
pybind11_add_build_test name
)
cmake_parse_arguments
(
ARG
"INSTALL"
""
""
${
ARGN
}
)
set
(
build_options
"-DCMAKE_PREFIX_PATH=
${
PROJECT_BINARY_DIR
}
/mock_install"
"-DCMAKE_CXX_COMPILER=
${
CMAKE_CXX_COMPILER
}
"
"-DPYTHON_EXECUTABLE:FILEPATH=
${
PYTHON_EXECUTABLE
}
"
"-DPYBIND11_CPP_STANDARD=
${
PYBIND11_CPP_STANDARD
}
"
)
if
(
NOT ARG_INSTALL
)
list
(
APPEND build_options
"-DPYBIND11_PROJECT_DIR=
${
PROJECT_SOURCE_DIR
}
"
)
endif
()
add_custom_target
(
test_
${
name
}
${
CMAKE_CTEST_COMMAND
}
--quiet --output-log test_cmake_build/
${
name
}
.log
--build-and-test
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/test_cmake_build/
${
name
}
"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/test_cmake_build/
${
name
}
"
--build-config Release
--build-noclean
--build-generator
${
CMAKE_GENERATOR
}
$<$<BOOL:
${
CMAKE_GENERATOR_PLATFORM
}
>:--build-generator-platform>
${
CMAKE_GENERATOR_PLATFORM
}
--build-makeprogram
${
CMAKE_MAKE_PROGRAM
}
--build-target check
--build-options
${
build_options
}
)
if
(
ARG_INSTALL
)
add_dependencies
(
test_
${
name
}
mock_install
)
endif
()
add_dependencies
(
test_cmake_build test_
${
name
}
)
endfunction
()
pybind11_add_build_test
(
subdirectory_function
)
pybind11_add_build_test
(
subdirectory_target
)
if
(
NOT
${
PYTHON_MODULE_EXTENSION
}
MATCHES
"pypy"
)
pybind11_add_build_test
(
subdirectory_embed
)
endif
()
if
(
PYBIND11_INSTALL
)
add_custom_target
(
mock_install
${
CMAKE_COMMAND
}
"-DCMAKE_INSTALL_PREFIX=
${
PROJECT_BINARY_DIR
}
/mock_install"
-P
"
${
PROJECT_BINARY_DIR
}
/cmake_install.cmake"
)
pybind11_add_build_test
(
installed_function INSTALL
)
pybind11_add_build_test
(
installed_target INSTALL
)
if
(
NOT
${
PYTHON_MODULE_EXTENSION
}
MATCHES
"pypy"
)
pybind11_add_build_test
(
installed_embed INSTALL
)
endif
()
endif
()
endif
()
add_dependencies
(
check test_cmake_build
)
add_subdirectory
(
test_cmake_build
)
tests/test_cmake_build/CMakeLists.txt
0 → 100644
View file @
c67033a9
add_custom_target
(
test_cmake_build
)
if
(
CMAKE_VERSION VERSION_LESS 3.1
)
# 3.0 needed for interface library for subdirectory_target/installed_target
# 3.1 needed for cmake -E env for testing
return
()
endif
()
include
(
CMakeParseArguments
)
function
(
pybind11_add_build_test name
)
cmake_parse_arguments
(
ARG
"INSTALL"
""
""
${
ARGN
}
)
set
(
build_options
"-DCMAKE_PREFIX_PATH=
${
PROJECT_BINARY_DIR
}
/mock_install"
"-DCMAKE_CXX_COMPILER=
${
CMAKE_CXX_COMPILER
}
"
"-DPYTHON_EXECUTABLE:FILEPATH=
${
PYTHON_EXECUTABLE
}
"
"-DPYBIND11_CPP_STANDARD=
${
PYBIND11_CPP_STANDARD
}
"
)
if
(
NOT ARG_INSTALL
)
list
(
APPEND build_options
"-DPYBIND11_PROJECT_DIR=
${
PROJECT_SOURCE_DIR
}
"
)
endif
()
add_custom_target
(
test_
${
name
}
${
CMAKE_CTEST_COMMAND
}
--quiet --output-log
${
name
}
.log
--build-and-test
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
name
}
"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
name
}
"
--build-config Release
--build-noclean
--build-generator
${
CMAKE_GENERATOR
}
$<$<BOOL:
${
CMAKE_GENERATOR_PLATFORM
}
>:--build-generator-platform>
${
CMAKE_GENERATOR_PLATFORM
}
--build-makeprogram
${
CMAKE_MAKE_PROGRAM
}
--build-target check
--build-options
${
build_options
}
)
if
(
ARG_INSTALL
)
add_dependencies
(
test_
${
name
}
mock_install
)
endif
()
add_dependencies
(
test_cmake_build test_
${
name
}
)
endfunction
()
pybind11_add_build_test
(
subdirectory_function
)
pybind11_add_build_test
(
subdirectory_target
)
if
(
NOT
${
PYTHON_MODULE_EXTENSION
}
MATCHES
"pypy"
)
pybind11_add_build_test
(
subdirectory_embed
)
endif
()
if
(
PYBIND11_INSTALL
)
add_custom_target
(
mock_install
${
CMAKE_COMMAND
}
"-DCMAKE_INSTALL_PREFIX=
${
PROJECT_BINARY_DIR
}
/mock_install"
-P
"
${
PROJECT_BINARY_DIR
}
/cmake_install.cmake"
)
pybind11_add_build_test
(
installed_function INSTALL
)
pybind11_add_build_test
(
installed_target INSTALL
)
if
(
NOT
${
PYTHON_MODULE_EXTENSION
}
MATCHES
"pypy"
)
pybind11_add_build_test
(
installed_embed INSTALL
)
endif
()
endif
()
add_dependencies
(
check test_cmake_build
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment