Skip to content

Commit

Permalink
let pybind find python, python libs and python includes
Browse files Browse the repository at this point in the history
  • Loading branch information
cklosters committed Jul 12, 2022
1 parent 0e8c9f1 commit d7c2ed9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 30 deletions.
12 changes: 0 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
cmake_minimum_required(VERSION 3.18.4)
project(NAP)

#if(WIN32)
# find_file(PYEXE
# NAMES python.exe
# HINTS
# c:/python35
# c:/python36
# )
# if(PYEXE)
# set(PYTHON_EXECUTABLE ${PYEXE})
# endif()
#endif()

# Keep the current directory as project root
set(NAP_ROOT ${CMAKE_CURRENT_LIST_DIR})
message(STATUS "Using NAP Root: ${CMAKE_CURRENT_LIST_DIR}")
Expand Down
17 changes: 5 additions & 12 deletions cmake/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -215,19 +215,12 @@ endmacro()
# Let find_python find our prepackaged Python in thirdparty. Used before a call to find_package(pybind11)
macro(find_python_in_thirdparty)
# Set our pre built Python location
set(PYTHONLIBS_FOUND 1)
if(UNIX)
if(APPLE)
set(PYTHON_PREFIX ${THIRDPARTY_DIR}/python/macos/x86_64)
else()
set(PYTHON_PREFIX ${THIRDPARTY_DIR}/python/linux/${ARCH})
endif()
set(PYTHON_LIBRARIES ${PYTHON_PREFIX}/lib/libpython3.6m${CMAKE_SHARED_LIBRARY_SUFFIX})
set(PYTHON_INCLUDE_DIRS ${PYTHON_PREFIX}/include/python3.6m)
if(APPLE)
set(PYTHON_EXECUTABLE ${THIRDPARTY_DIR}/python/macos/x86_64/bin/python3)
elseif(MSVC)
set(PYTHON_EXECUTABLE ${THIRDPARTY_DIR}/python/msvc/x86_64/python.exe)
else()
set(PYTHON_PREFIX ${THIRDPARTY_DIR}/python/msvc/x86_64)
set(PYTHON_LIBRARIES ${PYTHON_PREFIX}/libs/python36.lib)
set(PYTHON_INCLUDE_DIRS ${PYTHON_PREFIX}/include)
set(PYTHON_EXECUTABLE ${THIRDPARTY_DIR}/python/linux/${ARCH}/bin/python3)
endif()
endmacro()

Expand Down
7 changes: 2 additions & 5 deletions dist/cmake/native/dist_shared_native.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,11 @@ endmacro()

# Set our environment so that find_package finds our pre-packaged Python in thirdparty
macro(find_python_in_thirdparty)
set(PYTHONLIBS_FOUND 1)
set(PYTHON_PREFIX ${THIRDPARTY_DIR}/python)
if(UNIX)
set(PYTHON_LIBRARIES ${PYTHON_PREFIX}/lib/libpython3.6m${CMAKE_SHARED_LIBRARY_SUFFIX})
set(PYTHON_INCLUDE_DIRS ${PYTHON_PREFIX}/include/python3.6m)
set(PYTHON_EXECUTABLE ${PYTHON_PREFIX}/bin/python3)
else()
set(PYTHON_LIBRARIES ${PYTHON_PREFIX}/libs/python36.lib)
set(PYTHON_INCLUDE_DIRS ${PYTHON_PREFIX}/include)
set(PYTHON_EXECUTABLE ${PYTHON_PREFIX}/python.exe)
endif()
endmacro()

Expand Down
2 changes: 1 addition & 1 deletion modules/nappython/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ source_group("sources" FILES ${SOURCES})

# Get our NAP modules dependencies from module.json
module_json_to_cmake()

add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADERS})
set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER Modules)

# Remove lib prefix on Unix libraries
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")

Expand Down

0 comments on commit d7c2ed9

Please sign in to comment.