- Notifications
You must be signed in to change notification settings - Fork0
Add vcpkg json to pybind and cmake projects#70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
92 changes: 92 additions & 0 deletionshatch_cpp/tests/test_project_cmake_vcpkg/CMakeLists.txt
This file contains hidden or 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,92 @@ | ||
| cmake_minimum_required(VERSION 3.20.0) | ||
| project(hatch-cpp-test-project-basic VERSION "0.1.0") | ||
| set(CMAKE_CXX_STANDARD 20) | ||
| include(CheckCCompilerFlag) | ||
| include(CheckLinkerFlag) | ||
| if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") | ||
| set(WIN32 ON) | ||
| set(MACOS OFF) | ||
| set(LINUX OFF) | ||
| elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | ||
| set(WIN32 OFF) | ||
| set(MACOS ON) | ||
| set(LINUX OFF) | ||
| else() | ||
| set(WIN32 OFF) | ||
| set(MACOS OFF) | ||
| set(LINUX ON) | ||
| endif() | ||
| option(CMAKE_BUILD_TYPE "Release/Debug build" RELEASE) | ||
| option(HATCH_CPP_TEST_PROJECT_BASIC_BUILD_TESTS "Build tests" OFF) | ||
| option(HATCH_CPP_TEST_PROJECT_BASIC_MANYLINUX "Build for python's manylinux setup" OFF) | ||
| string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER) | ||
| set(BUILD_SHARED_LIBS TRUE) | ||
| set(CMAKE_MACOSX_RPATH TRUE) | ||
| set(CMAKE_SKIP_RPATH FALSE) | ||
| set(CMAKE_SKIP_BUILD_RPATH FALSE) | ||
| set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) | ||
| set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) | ||
| set(CMAKE_INSTALL_NAME_DIR "@rpath") | ||
| set(CMAKE_POSITION_INDEPENDENT_CODE ON) | ||
| string(REGEX REPLACE "[ ]*-O[^ ]+[ ]*" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") | ||
| string(REGEX REPLACE "[ ]*-Wl,-O2 -Wl,[^ ]+[ ]*" " " CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") | ||
| string(REGEX REPLACE "[ ]*-Wl,-O2 -Wl,[^ ]+[ ]*" " " CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") | ||
| if(MACOS) | ||
| set(CMAKE_THREAD_LIBS_INIT "-lpthread") | ||
| set(CMAKE_HAVE_THREADS_LIBRARY 1) | ||
| set(CMAKE_USE_WIN32_THREADS_INIT 0) | ||
| set(CMAKE_USE_PTHREADS_INIT 1) | ||
| set(THREADS_PREFER_PTHREAD_FLAG ON) | ||
| set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -undefined dynamic_lookup") | ||
| endif() | ||
| if(MACOS) | ||
| set(CMAKE_INSTALL_RPATH "@loader_path/") | ||
| elseif(LINUX) | ||
| set(CMAKE_INSTALL_RPATH "\$ORIGIN") | ||
| endif() | ||
| if(WIN32) | ||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /MP /bigobj") | ||
| foreach(warning 4244 4251 4267 4275 4290 4786 4305 4996) | ||
| SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd${warning}") | ||
| endforeach(warning) | ||
| else() | ||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \ | ||
| -g \ | ||
| -Wall \ | ||
| -Werror \ | ||
| -Wno-deprecated-declarations \ | ||
| -Wno-deprecated \ | ||
| ") | ||
| endif() | ||
| find_package(Python ${CSP_PYTHON_VERSION} EXACT REQUIRED COMPONENTS Interpreter Development.Module) | ||
| link_directories(${Python_LIBRARY_DIRS}) | ||
| include_directories(${Python_INCLUDE_DIRS}) | ||
| set(CMAKE_SHARED_LIBRARY_PREFIX "") | ||
| if(NOT WIN32) | ||
| set(CMAKE_SHARED_LIBRARY_SUFFIX .so) | ||
| else() | ||
| set(CMAKE_SHARED_LIBRARY_SUFFIX .pyd) | ||
| endif() | ||
| include_directories("${CMAKE_SOURCE_DIR}/cpp") | ||
| add_library(extension SHARED cpp/project/basic.cpp) | ||
| set_target_properties(extension PROPERTIES PUBLIC_HEADER cpp/project/basic.hpp) | ||
| install(TARGETS extension | ||
| PUBLIC_HEADER DESTINATION project/include/project | ||
| RUNTIME DESTINATION project/ | ||
| LIBRARY DESTINATION project/ | ||
| ) |
140 changes: 140 additions & 0 deletionshatch_cpp/tests/test_project_cmake_vcpkg/Makefile
This file contains hidden or 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,140 @@ | ||
| # CMAKE generated file: DO NOT EDIT! | ||
| # Generated by "Unix Makefiles" Generator, CMake Version 3.31 | ||
| # Default target executed when no arguments are given to make. | ||
| default_target: all | ||
| .PHONY : default_target | ||
| # Allow only one "make -f Makefile2" at a time, but pass parallelism. | ||
| .NOTPARALLEL: | ||
| #============================================================================= | ||
| # Special targets provided by cmake. | ||
| # Disable implicit rules so canonical targets will work. | ||
| .SUFFIXES: | ||
| # Disable VCS-based implicit rules. | ||
| % : %,v | ||
| # Disable VCS-based implicit rules. | ||
| % : RCS/% | ||
| # Disable VCS-based implicit rules. | ||
| % : RCS/%,v | ||
| # Disable VCS-based implicit rules. | ||
| % : SCCS/s.% | ||
| # Disable VCS-based implicit rules. | ||
| % : s.% | ||
| .SUFFIXES: .hpux_make_needs_suffix_list | ||
| # Command-line flag to silence nested $(MAKE). | ||
| $(VERBOSE)MAKESILENT = -s | ||
| #Suppress display of executed commands. | ||
| $(VERBOSE).SILENT: | ||
| # A target that is always out of date. | ||
| cmake_force: | ||
| .PHONY : cmake_force | ||
| #============================================================================= | ||
| # Set environment variables for the build. | ||
| # The shell in which to execute make rules. | ||
| SHELL = /bin/sh | ||
| # The CMake executable. | ||
| CMAKE_COMMAND = /opt/homebrew/bin/cmake | ||
| # The command to remove a file. | ||
| RM = /opt/homebrew/bin/cmake -E rm -f | ||
| # Escaping for special characters. | ||
| EQUALS = = | ||
| # The top-level source directory on which CMake was run. | ||
| CMAKE_SOURCE_DIR = /Users/timkpaine/Developer/projects/templates/hatch-cpp/hatch_cpp/tests/test_project_cmake | ||
| # The top-level build directory on which CMake was run. | ||
| CMAKE_BINARY_DIR = /Users/timkpaine/Developer/projects/templates/hatch-cpp/hatch_cpp/tests/test_project_cmake | ||
| #============================================================================= | ||
| # Targets provided globally by CMake. | ||
| # Special rule for the target edit_cache | ||
| edit_cache: | ||
| @$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Running CMake cache editor..." | ||
| /opt/homebrew/bin/ccmake -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) | ||
| .PHONY : edit_cache | ||
| # Special rule for the target edit_cache | ||
| edit_cache/fast: edit_cache | ||
| .PHONY : edit_cache/fast | ||
| # Special rule for the target rebuild_cache | ||
| rebuild_cache: | ||
| @$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Running CMake to regenerate build system..." | ||
| /opt/homebrew/bin/cmake --regenerate-during-build -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) | ||
| .PHONY : rebuild_cache | ||
| # Special rule for the target rebuild_cache | ||
| rebuild_cache/fast: rebuild_cache | ||
| .PHONY : rebuild_cache/fast | ||
| # The main all target | ||
| all: cmake_check_build_system | ||
| $(CMAKE_COMMAND) -E cmake_progress_start /Users/timkpaine/Developer/projects/templates/hatch-cpp/hatch_cpp/tests/test_project_cmake/CMakeFiles /Users/timkpaine/Developer/projects/templates/hatch-cpp/hatch_cpp/tests/test_project_cmake//CMakeFiles/progress.marks | ||
| $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 all | ||
| $(CMAKE_COMMAND) -E cmake_progress_start /Users/timkpaine/Developer/projects/templates/hatch-cpp/hatch_cpp/tests/test_project_cmake/CMakeFiles 0 | ||
| .PHONY : all | ||
| # The main clean target | ||
| clean: | ||
| $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 clean | ||
| .PHONY : clean | ||
| # The main clean target | ||
| clean/fast: clean | ||
| .PHONY : clean/fast | ||
| # Prepare targets for installation. | ||
| preinstall: all | ||
| $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 preinstall | ||
| .PHONY : preinstall | ||
| # Prepare targets for installation. | ||
| preinstall/fast: | ||
| $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 preinstall | ||
| .PHONY : preinstall/fast | ||
| # clear depends | ||
| depend: | ||
| $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 | ||
| .PHONY : depend | ||
| # Help Target | ||
| help: | ||
| @echo "The following are some of the valid targets for this Makefile:" | ||
| @echo "... all (the default if no target is provided)" | ||
| @echo "... clean" | ||
| @echo "... depend" | ||
| @echo "... edit_cache" | ||
| @echo "... rebuild_cache" | ||
| .PHONY : help | ||
| #============================================================================= | ||
| # Special targets to cleanup operation of make. | ||
| # Special rule to run CMake to check the build system integrity. | ||
| # No rule that depends on this can have commands that come from listfiles | ||
| # because they might be regenerated. | ||
| cmake_check_build_system: | ||
| $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 | ||
| .PHONY : cmake_check_build_system | ||
5 changes: 5 additions & 0 deletionshatch_cpp/tests/test_project_cmake_vcpkg/cpp/project/basic.cpp
This file contains hidden or 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,5 @@ | ||
| #include "project/basic.hpp" | ||
| PyObject* hello(PyObject*, PyObject*) { | ||
| return PyUnicode_FromString("A string"); | ||
| } |
17 changes: 17 additions & 0 deletionshatch_cpp/tests/test_project_cmake_vcpkg/cpp/project/basic.hpp
This file contains hidden or 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,17 @@ | ||
| #pragma once | ||
| #include "Python.h" | ||
| PyObject* hello(PyObject*, PyObject*); | ||
| static PyMethodDef extension_methods[] = { | ||
| {"hello", (PyCFunction)hello, METH_NOARGS}, | ||
| {nullptr, nullptr, 0, nullptr} | ||
| }; | ||
| static PyModuleDef extension_module = { | ||
| PyModuleDef_HEAD_INIT, "extension", "extension", -1, extension_methods}; | ||
| PyMODINIT_FUNC PyInit_extension(void) { | ||
| Py_Initialize(); | ||
| return PyModule_Create(&extension_module); | ||
| } |
Empty file addedhatch_cpp/tests/test_project_cmake_vcpkg/project/__init__.py
Empty file.
17 changes: 17 additions & 0 deletionshatch_cpp/tests/test_project_cmake_vcpkg/project/include/project/basic.hpp
This file contains hidden or 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,17 @@ | ||
| #pragma once | ||
| #include "Python.h" | ||
| PyObject* hello(PyObject*, PyObject*); | ||
| static PyMethodDef extension_methods[] = { | ||
| {"hello", (PyCFunction)hello, METH_NOARGS}, | ||
| {nullptr, nullptr, 0, nullptr} | ||
| }; | ||
| static PyModuleDef extension_module = { | ||
| PyModuleDef_HEAD_INIT, "extension", "extension", -1, extension_methods}; | ||
| PyMODINIT_FUNC PyInit_extension(void) { | ||
| Py_Initialize(); | ||
| return PyModule_Create(&extension_module); | ||
| } |
39 changes: 39 additions & 0 deletionshatch_cpp/tests/test_project_cmake_vcpkg/pyproject.toml
This file contains hidden or 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,39 @@ | ||
| [build-system] | ||
| requires = ["hatchling>=1.20"] | ||
| build-backend = "hatchling.build" | ||
| [project] | ||
| name = "hatch-cpp-test-project-basic" | ||
| description = "Basic test project for hatch-cpp" | ||
| version = "0.1.0" | ||
| requires-python = ">=3.9" | ||
| dependencies = [ | ||
| "hatchling>=1.20", | ||
| "hatch-cpp", | ||
| ] | ||
| [tool.hatch.build] | ||
| artifacts = [ | ||
| "project/*.dll", | ||
| "project/*.dylib", | ||
| "project/*.so", | ||
| ] | ||
| [tool.hatch.build.sources] | ||
| src = "/" | ||
| [tool.hatch.build.targets.sdist] | ||
| packages = ["project"] | ||
| [tool.hatch.build.targets.wheel] | ||
| packages = ["project"] | ||
| [tool.hatch.build.hooks.hatch-cpp] | ||
| verbose = true | ||
| [tool.hatch.build.hooks.hatch-cpp.cmake] | ||
| root = "CMakeLists.txt" | ||
| cmake_args = {"BUILD_TESTS" = "OFF"} | ||
| include_flags = {"python_version" = true} | ||
| [tool.hatch.build.hooks.hatch-cpp.cmake.cmake_env_args] | ||
| linux = {"MANYLINUX" = "ON"} |
8 changes: 8 additions & 0 deletionshatch_cpp/tests/test_project_cmake_vcpkg/vcpkg.json
This file contains hidden or 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,8 @@ | ||
| { | ||
| "name": "main", | ||
| "version-string": "latest", | ||
| "dependencies": [ | ||
| "arrow" | ||
| ], | ||
| "builtin-baseline": "b94ade01f19e4436d8c8a16a5c52e8c802ef67dd" | ||
| } |
6 changes: 6 additions & 0 deletionshatch_cpp/tests/test_project_pybind_vcpkg/cpp/project/basic.cpp
This file contains hidden or 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,6 @@ | ||
| #include "project/basic.hpp" | ||
| std::string hello() { | ||
| return "A string"; | ||
| } | ||
9 changes: 9 additions & 0 deletionshatch_cpp/tests/test_project_pybind_vcpkg/cpp/project/basic.hpp
This file contains hidden or 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,9 @@ | ||
| #pragma once | ||
| #include <pybind11/pybind11.h> | ||
| #include <string> | ||
| std::string hello(); | ||
| PYBIND11_MODULE(extension, m) { | ||
| m.def("hello", &hello); | ||
| } |
Empty file addedhatch_cpp/tests/test_project_pybind_vcpkg/project/__init__.py
Empty file.
35 changes: 35 additions & 0 deletionshatch_cpp/tests/test_project_pybind_vcpkg/pyproject.toml
This file contains hidden or 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,35 @@ | ||
| [build-system] | ||
| requires = ["hatchling>=1.20"] | ||
| build-backend = "hatchling.build" | ||
| [project] | ||
| name = "hatch-cpp-test-project-pybind" | ||
| description = "Basic test project for hatch-cpp" | ||
| version = "0.1.0" | ||
| requires-python = ">=3.9" | ||
| dependencies = [ | ||
| "hatchling>=1.20", | ||
| "hatch-cpp", | ||
| ] | ||
| [tool.hatch.build] | ||
| artifacts = [ | ||
| "project/*.dll", | ||
| "project/*.dylib", | ||
| "project/*.so", | ||
| ] | ||
| [tool.hatch.build.sources] | ||
| src = "/" | ||
| [tool.hatch.build.targets.sdist] | ||
| packages = ["project"] | ||
| [tool.hatch.build.targets.wheel] | ||
| packages = ["project"] | ||
| [tool.hatch.build.hooks.hatch-cpp] | ||
| verbose = true | ||
| libraries = [ | ||
| {name = "project/extension", sources = ["cpp/project/basic.cpp"], include-dirs = ["cpp"], binding="pybind11"}, | ||
| ] |
8 changes: 8 additions & 0 deletionshatch_cpp/tests/test_project_pybind_vcpkg/vcpkg.json
This file contains hidden or 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,8 @@ | ||
| { | ||
| "name": "main", | ||
| "version-string": "latest", | ||
| "dependencies": [ | ||
| "arrow" | ||
| ], | ||
| "builtin-baseline": "b94ade01f19e4436d8c8a16a5c52e8c802ef67dd" | ||
| } |
2 changes: 2 additions & 0 deletionshatch_cpp/tests/test_projects.py
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.