forked from scikit-build/scikit-build
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add cmake_target to change the target used by CMake (scikit-bui…
…ld#477) Parses the command line for the `--target` option. And also provide the `cmake_install_target` parameter in `setup.py` The command line argument has preference over the `cmake_install_target` from `setup.py`. This allows the user to point to targets other than 'install'. The user has to set a target in CMake to install only a specific component. ```cmake install(TARGETS foo COMPONENT runtime) add_custom_target(foo-install-runtime ${CMAKE_COMMAND} -DCMAKE_INSTALL_COMPONENT=runtime -P "${PROJECT_BINARY_DIR}/cmake_install.cmake") ``` DevNote: There is a refactor of the function `cmaker.make` That allows calling the function twice in case the target is not the default `install`.
- Loading branch information
Showing
8 changed files
with
187 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
cmake_minimum_required(VERSION 3.5.0) | ||
project(test-cmake-target NONE) | ||
file(WRITE "${CMAKE_BINARY_DIR}/foo.txt" "# foo") | ||
file(WRITE "${CMAKE_BINARY_DIR}/runtime.txt" "# runtime") | ||
install(FILES "${CMAKE_BINARY_DIR}/foo.txt" DESTINATION ".") | ||
install(CODE "message(STATUS \"Project has been installed\")") | ||
install(FILES "${CMAKE_BINARY_DIR}/runtime.txt" DESTINATION "." COMPONENT runtime) | ||
install(CODE "message(STATUS \"Runtime component has been installed\")" COMPONENT runtime) | ||
# Add custom target to only install component: runtime (libraries) | ||
add_custom_target(install-runtime | ||
${CMAKE_COMMAND} | ||
-DCMAKE_INSTALL_COMPONENT=runtime | ||
-P "${PROJECT_BINARY_DIR}/cmake_install.cmake" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from skbuild import setup | ||
|
||
setup( | ||
name="test-cmake-target", | ||
version="1.2.3", | ||
description="a minimal example package using a non-default target", | ||
author='The scikit-build team', | ||
license="MIT", | ||
cmake_target="install-runtime", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
"""test_cmake_target | ||
---------------------------------- | ||
Tries to build and test the `test-cmake-target` sample | ||
project. It basically checks that using the `cmake_target` keyword | ||
in setup.py works. | ||
""" | ||
|
||
from . import project_setup_py_test | ||
|
||
|
||
@project_setup_py_test("test-cmake-target", ["build"], disable_languages_test=True) | ||
def test_cmake_target_build(capsys): | ||
out, err = capsys.readouterr() | ||
dist_warning = "Unknown distribution option: 'cmake_target'" | ||
assert (dist_warning not in err and dist_warning not in out) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters