Skip to content

Commit ae5b5a7

Browse files
authored
CMake fixes (#275)
1 parent f2ba6ac commit ae5b5a7

File tree

7 files changed

+18
-20
lines changed

7 files changed

+18
-20
lines changed

.github/workflows/CI.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ jobs:
8282
mkdir build && cd build
8383
cmake .. \
8484
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
85-
-DPYTHON_EXECUTABLE=`which python3` \
85+
-DPython3_EXECUTABLE=`which python3` \
8686
-DSERIALBOX_TESTING=ON \
8787
-DSERIALBOX_ENABLE_FORTRAN=${TEST_FORTRAN} \
8888
-DSERIALBOX_TESTING_FORTRAN=${TEST_FORTRAN} \

CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/install" CACHE PATH "CMake install prefix")
1515

1616
cmake_policy(SET CMP0048 NEW)
17-
project(Serialbox LANGUAGES C CXX VERSION 2.6.1)
1817
cmake_minimum_required(VERSION 3.12.0)
18+
project(Serialbox LANGUAGES C CXX VERSION 2.6.1)
1919

2020
set(CMAKE_CXX_EXTENSIONS OFF)
2121
set(CMAKE_C_EXTENSIONS OFF)
@@ -218,7 +218,7 @@ endif()
218218

219219
#---------------------------------------- Python ---------------------------------------------------
220220
if(SERIALBOX_ENABLE_PYTHON)
221-
find_package(PythonInterp 3.4)
221+
find_package(Python3 COMPONENTS Interpreter)
222222

223223
# Python tests are enabled by default if we can find "nose" and "numpy"
224224
set(ENABLE_PYTHON_TESTS OFF)

cmake/SerialboxTooling.cmake

+1-2
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,11 @@ function(serialbox_run_pp_ser)
8989

9090
if(pp_ser_input)
9191
add_custom_command(OUTPUT ${pp_ser_output}
92-
COMMAND ${PYTHON_EXECUTABLE} ${SERIALBOX_PPSER} --verbose
92+
COMMAND ${Python3_EXECUTABLE} ${SERIALBOX_PPSER} --verbose
9393
--ignore-identical
9494
--output-dir=${output_dir}
9595
${pp_ser_input}
9696
DEPENDS ${pp_ser_input}
9797
COMMENT "Preprocessing for serialization")
9898
endif()
9999
endfunction(serialbox_run_pp_ser)
100-

cmake/modules/FindPythonModule.cmake

+5-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# find_python_module(PyQt5 REQUIRED)
66
#
7-
# The module makes use of the ${PYTHON_EXECUTABLE} which needs to be set before calling the
7+
# The module makes use of the ${Python3_EXECUTABLE} which needs to be set before calling the
88
# find_python_module function.
99
#
1010
# Variables defined by this cmake module:
@@ -25,7 +25,7 @@ function(find_python_module module)
2525
endif()
2626

2727
# A module's location is usually a directory, but for binary modules it's a .so file.
28-
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c"
28+
execute_process(COMMAND "${Python3_EXECUTABLE}" "-c"
2929
"import re, ${module}; print(re.compile('/__init__.py.*').sub('',${module}.__file__))"
3030
RESULT_VARIABLE _${module}_status
3131
OUTPUT_VARIABLE _${module}_location
@@ -34,7 +34,7 @@ function(find_python_module module)
3434

3535
# Set result
3636
if(NOT _${module}_status)
37-
message(STATUS "Found Python module \"${module}\" for Python: ${PYTHON_EXECUTABLE}")
37+
message(STATUS "Found Python module \"${module}\" for Python: ${Python3_EXECUTABLE}")
3838
set(PY_${module_upper}_PATH ${_${module}_location}
3939
CACHE STRING "Location of Python module ${module}")
4040
set(PY_${module_upper}_FOUND TRUE
@@ -43,11 +43,10 @@ function(find_python_module module)
4343
else()
4444
set(PY_${module_upper}_FOUND FALSE)
4545
if(${module}_FIND_REQUIRED)
46-
message(FATAL_ERROR "Could NOT find module ${module} for python ${PYTHON_EXECUTABLE}")
46+
message(FATAL_ERROR "Could NOT find module ${module} for python ${Python3_EXECUTABLE}")
4747
else()
48-
message(STATUS "Could NOT find \"${module}\" for python: ${PYTHON_EXECUTABLE}")
48+
message(STATUS "Could NOT find \"${module}\" for python: ${Python3_EXECUTABLE}")
4949
endif()
5050
endif()
5151
endif(NOT PY_${module_upper}_FOUND)
5252
endfunction(find_python_module)
53-

src/serialbox-python/setup.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,17 @@ def build_extension(self, ext):
4545
# Can be set with Conda-Build, for example.
4646
cmake_generator = os.environ.get("CMAKE_GENERATOR", "")
4747

48-
# Set Python_EXECUTABLE instead if you use PYBIND11_FINDPYTHON
48+
# Set Python3_EXECUTABLE instead if you use PYBIND11_FINDPYTHON
4949
# EXAMPLE_VERSION_INFO shows you how to pass a value into the C++ code
5050
# from Python.
5151
cmake_args = [
5252
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={}".format(extdir),
53-
"-DPYTHON_EXECUTABLE={}".format(sys.executable),
53+
"-DPython3_EXECUTABLE={}".format(sys.executable),
5454
"-DCMAKE_BUILD_TYPE={}".format(cfg), # not used on MSVC, but no harm
5555
"-DSERIALBOX_ENABLE_FORTRAN=false",
5656
"-DCMAKE_BUILD_RPATH={}".format(origin),
5757
"-DSERIALBOX_ENABLE_SDB=false",
5858
"-DSERIALBOX_ASYNC_API=false",
59-
6059
]
6160
build_args = []
6261
# Adding CMake arguments set as environment variable
@@ -70,6 +69,7 @@ def build_extension(self, ext):
7069
]
7170
if sys.platform == "darwin":
7271
from distutils import sysconfig
72+
7373
vars = sysconfig.get_config_vars()
7474
vars["SO"] = ".dylib"
7575
vars["EXT_SUFFIX"] = ".dylib"
@@ -89,7 +89,6 @@ def build_extension(self, ext):
8989
pass
9090

9191
else:
92-
9392
# Single config generators are handled "normally"
9493
single_config = any(x in cmake_generator for x in {"NMake", "Ninja"})
9594

@@ -151,7 +150,9 @@ def _get_origin(self):
151150
author="Serialbox Developers",
152151
packages=find_packages(),
153152
install_requires=["numpy"],
154-
ext_modules=[CMakeExtension("libSerialboxC", sourcedir=os.path.join(DIR, "../../"))],
153+
ext_modules=[
154+
CMakeExtension("libSerialboxC", sourcedir=os.path.join(DIR, "../../"))
155+
],
155156
cmdclass={"build_ext": CMakeBuild},
156157
zip_safe=False,
157158
)

src/serialbox/core/hash/Hash.h

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ class Hash {
3636
///
3737
/// \return Hex representation as string of the computed hash
3838
virtual std::string hash(const void* data, int length) = 0;
39-
4039
virtual ~Hash() = default;
4140
};
4241

test/serialbox-python/run_python_tests.sh.cmake

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${PROJECT_BINARY_DIR}/src/serialbox-c"
2323
#
2424
# Check if nose exists
2525
#
26-
"${PYTHON_EXECUTABLE}" -c "import nose"
26+
"${Python3_EXECUTABLE}" -c "import nose"
2727
if [ "$?" == "1" ]; then
2828
echo ">> Python tests require module 'nose'"
2929
exit 1
@@ -33,10 +33,10 @@ fi
3333
# Run serialbox python tests with nose
3434
#
3535
cd "${PYTHON_TEST_DIR}/serialbox"
36-
"${PYTHON_EXECUTABLE}" -m "nose"
36+
"${Python3_EXECUTABLE}" -m "nose"
3737

3838
#
3939
# Run the sdb tests with nose
4040
#
4141
cd "${PYTHON_TEST_DIR}/sdb/sdbcore"
42-
"${PYTHON_EXECUTABLE}" -m "nose"
42+
"${Python3_EXECUTABLE}" -m "nose"

0 commit comments

Comments
 (0)