Open lionlai1989 opened 1 year ago
@lionlai1989
I did something similar yesterday, by adding set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
to cmake, executables were added to pip wheel.
Example code: https://github.com/cubao/cubao-tippecanoe/blob/pypi-release/CMakeLists.txt
$ unzip -l dist/cubao_tippecanoe-0.0.1-cp310-cp310-linux_x86_64.whl
Archive: dist/cubao_tippecanoe-0.0.1-cp310-cp310-linux_x86_64.whl
Length Date Time Name
--------- ---------- ----- ----
1773952 2023-09-17 15:38 __cubao_tippecanoe_decode.exe
1301248 2023-09-17 15:38 __cubao_tippecanoe_enumerate.exe
78640 2023-09-17 15:38 __cubao_tippecanoe_jsontool.exe
537496 2023-09-17 15:38 __cubao_tippecanoe_overzoom.exe
2123648 2023-09-17 15:38 __cubao_tippecanoe_tile-join.exe
2657384 2023-09-17 15:38 __cubao_tippecanoe_tippecanoe.exe
175960 2023-09-17 15:38 _pybind11_tippecanoe.cpython-310-x86_64-linux-gnu.so
95 2023-09-17 09:11 cubao_tippecanoe/__init__.py
687 2023-09-17 15:31 cubao_tippecanoe/__main__.py
1329 2023-09-17 15:38 cubao_tippecanoe-0.0.1.dist-info/LICENSE.md
63751 2023-09-17 15:38 cubao_tippecanoe-0.0.1.dist-info/METADATA
105 2023-09-17 15:38 cubao_tippecanoe-0.0.1.dist-info/WHEEL
17 2023-09-17 15:38 cubao_tippecanoe-0.0.1.dist-info/top_level.txt
1259 2023-09-17 15:38 cubao_tippecanoe-0.0.1.dist-info/RECORD
--------- -------
8715571 14 files
Hello, I'm currently learning how to use CMake and pybind11 with this project. As part of the installation process, I need to build and install a C++ source file. To ensure that everything is clear, I've included the reproduction code below.
Description
helloworld.cpp
insrc/
folder.src/helloworld.cpp
: A trivial helloworld program.$ cat src/helloworld.cpp
int main(int argc, char **argv) { std::cout << "Hello World!!!\n"; return 0; }
$ cat CMakeLists.txt cmake_minimum_required(VERSION 3.22) project(cmake_example)
add_executable(helloworld src/helloworld.cpp)
add_subdirectory(pybind11) pybind11_add_module(cmake_example src/main.cpp)
target_compile_definitions(cmake_example PRIVATE VERSION_INFO=${EXAMPLE_VERSION_INFO})
$ cat pyproject.toml [build-system] requires = ["setuptools>=62.0.0", "wheel", "cmake>=3.22"] build-backend = "setuptools.build_meta"
$ ls venv/lib/python3.8/site-packages/ cmake_example-0.0.1.dist-info
cmake_example.cpython-38-x86_64-linux-gnu.so
$ ls cmake_example.cpython-38-x86_64-linux-gnu.so cmake_example.egg-info CMakeLists.txt pybind11 pyproject.toml setup.py src venv