Commit c05d0651 authored by Roel Aaij's avatar Roel Aaij
Browse files

Make build work with setup.py.

parent 4588ed09
......@@ -96,14 +96,6 @@ endif()
# install(DIRECTORY ${Vc_DESTDIR}/ DESTINATION ".")
if(ENABLE_PYTHON)
# pybind11
find_package(pybind11 QUIET)
if (NOT pybind11_FOUND)
message(STATUS "Assuming pybind11 is installed in python site-packages")
endif()
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
set(CMAKE_CXX_STANDARD 17)
......@@ -155,9 +147,24 @@ endif()
if(ENABLE_PYTHON)
include(pybind11Tools)
pybind11_add_module(k40gen "src/k40gen/bindings.cpp")
target_include_directories(k40gen PRIVATE ${PYTHON_SITE_PACKAGES}/numpy/core/include)
target_include_directories(k40gen PRIVATE ${PYTHON_SITE_PACKAGES})
target_link_libraries(k40gen PUBLIC generate)
# pybind11 headers
if("${PYBIND11_INCLUDE_DIR}" STREQUAL "")
find_package(pybind11 QUIET)
if (NOT pybind11_FOUND)
message(FAILURE "PYBIND11_INCLUDE_DIR is not set and pybind11 cannot be found")
endif()
else()
endif()
# numpy headers
if("${NUMPY_INCLUDE_DIR}" STREQUAL "")
message(STATUS "Assuming numpy headers are installed in python site packages location")
target_include_directories(k40gen PRIVATE ${PYTHON_SITE_PACKAGES}/numpy/core/include)
else()
target_include_directories(k40gen PRIVATE ${NUMPY_INCLUDE_DIR})
endif()
endif()
if(ENABLE_TESTS)
......
from distutils.version import LooseVersion
from setuptools import setup, find_packages, Extension
from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
import sys
import os
import setuptools
import re
import sysconfig
import platform
import subprocess
import numpy as np
import pybind11
__version__ = '0.0.1'
......@@ -41,6 +41,8 @@ class CMakeBuild(build_ext):
os.path.dirname(self.get_ext_fullpath(ext.name)))
cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir,
'-DPYTHON_EXECUTABLE=' + sys.executable]
cmake_args += ['-DNUMPY_INCLUDE_DIR=' + np.get_include()]
cmake_args += ['-DPYBIND11_INCLUDE_DIR=' + pybind11.get_include()]
cfg = 'Debug' if self.debug else 'Release'
build_args = ['--config', cfg]
......@@ -54,7 +56,7 @@ class CMakeBuild(build_ext):
build_args += ['--', '/m']
else:
cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg]
build_args += ['--', '-j2']
build_args += ['--', '-j1']
env = os.environ.copy()
env['CXXFLAGS'] = '{} -DVERSION_INFO=\\"{}\\"'.format(
......
......@@ -16,10 +16,11 @@ if(NOT Catch2_FOUND)
BUILD_COMMAND ""
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy <DOWNLOADED_FILE> <INSTALL_DIR>
STEP_TARGETS install)
set(Catch2_FOUND TRUE)
set(builtin_catch TRUE)
include_directories(${CMAKE_BINARY_DIR}/include)
set(builtin_Catch2 TRUE)
else()
set(builtin_catch FALSE)
include_directories(${Catch2_INCLUDE_DIR})
set(builtin_Catch2 FALSE)
endif()
include_directories(include)
......@@ -37,18 +38,24 @@ add_executable(test_k40gen
src/test_rates.cpp
src/test_main.cpp)
if(builtin_Catch2)
add_dependencies(test_k40gen catch-install)
endif()
target_link_libraries(test_k40gen PRIVATE generate test_functions)
add_test(TestK40 test_k40gen)
find_package(ROOT COMPONENTS Core Cling Hist Gpad)
add_executable(test_k40gen_root
src/test_rates_root.cpp)
target_include_directories(test_k40gen_root PRIVATE
${ROOT_INCLUDE_DIRS})
target_link_libraries(test_k40gen_root PRIVATE
generate
test_functions
${ROOT_LIBRARIES})
# Optional test binary based on ROOT
find_package(ROOT QUIET COMPONENTS Core Cling Hist Gpad)
if (ROOT_FOUND)
add_executable(test_k40gen_root
src/test_rates_root.cpp)
target_include_directories(test_k40gen_root PRIVATE
${ROOT_INCLUDE_DIRS})
target_link_libraries(test_k40gen_root PRIVATE
generate
test_functions
${ROOT_LIBRARIES})
endif()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment