Skip to content

Commit

Permalink
cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
jschueller committed Dec 3, 2024
1 parent 1ec4b64 commit 200edb0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 97 deletions.
10 changes: 3 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# Benoit Scherrer, 2010 CRL, Harvard Medical School
# Copyright (c) 2008-2009 Children's Hospital Boston
#==============================================================================
cmake_minimum_required (VERSION 3.13)
cmake_minimum_required (VERSION 3.14)

set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type")

Expand Down Expand Up @@ -324,13 +324,9 @@ endif ()

if (NLOPT_PYTHON)
if (CMAKE_VERSION VERSION_LESS 3.26)
find_package (Python 3.6 COMPONENTS Interpreter Development)
find_package (Python 3.6 COMPONENTS Interpreter Development NumPy)
else ()
find_package (Python 3.6 COMPONENTS Interpreter Development.Module Development.SABIModule)
endif ()

if (Python_FOUND)
find_package (NumPy)
find_package (Python 3.6 COMPONENTS Interpreter Development.Module Development.SABIModule NumPy)
endif ()
endif ()

Expand Down
86 changes: 0 additions & 86 deletions cmake/FindNumPy.cmake

This file was deleted.

7 changes: 4 additions & 3 deletions src/swig/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@ endif ()
include_directories (${NLOPT_PRIVATE_INCLUDE_DIRS})
set_source_files_properties (nlopt.i PROPERTIES CPLUSPLUS ON)

if (NUMPY_FOUND AND Python_FOUND)
if (Python_NumPy_FOUND)

set (SWIG_MODULE_nlopt_python_EXTRA_DEPS nlopt-python.i numpy.i generate-cpp)

# swig_add_module is deprecated
swig_add_library (nlopt_python LANGUAGE python SOURCES nlopt.i)

target_include_directories (nlopt_python PRIVATE ${Python_INCLUDE_DIRS})
target_include_directories (nlopt_python PRIVATE ${NUMPY_INCLUDE_DIRS})
target_include_directories (nlopt_python PRIVATE ${Python_NumPy_INCLUDE_DIRS})

swig_link_libraries (nlopt_python ${nlopt_lib})
target_link_libraries (nlopt_python ${nlopt_lib})
target_link_libraries (nlopt_python Python::NumPy)
if (TARGET Python::Module)
target_link_libraries (nlopt_python Python::Module)
else ()
Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ foreach (algo_index RANGE 28) # 42
endforeach ()
endforeach ()

if (Python_FOUND AND NUMPY_FOUND AND (SWIG_FOUND OR (EXISTS ${PROJECT_SOURCE_DIR}/src/swig/nlopt-python.cpp)))
if (Python_NumPy_FOUND AND (SWIG_FOUND OR (EXISTS ${PROJECT_SOURCE_DIR}/src/swig/nlopt-python.cpp)))
set (PYINSTALLCHECK_ENVIRONMENT "LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}/src/swig"
"PYTHONPATH=${PROJECT_BINARY_DIR}/src/swig"
)
Expand Down

0 comments on commit 200edb0

Please sign in to comment.