Commit 986d05c5 authored by Guilhem Saurel's avatar Guilhem Saurel

[CMake] split export in interface + python component

parent b78ef66b
......@@ -60,11 +60,25 @@ SET(${PYWRAP}_INSTALL_DIR "${PYTHON_SITELIB}/${PROJECT_NAME}")
# ----------------------------------------------------
# --- DEPENDENCIES -----------------------------------
# ----------------------------------------------------
ADD_PROJECT_DEPENDENCY(Eigen3 REQUIRED PKG_CONFIG_REQUIRES "eigen3 >= 3.0.5")
ADD_PROJECT_DEPENDENCY(Eigen3 REQUIRED)
SET(BOOST_COMPONENTS python)
SEARCH_FOR_BOOST()
# ----------------------------------------------------
# --- INTERFACE --------------------------------------
# ----------------------------------------------------
ADD_LIBRARY(${PROJECT_NAME} INTERFACE)
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME}
SYSTEM INTERFACE
${Boost_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR}
INTERFACE
#$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include> # TODO: do we really need that ?
$<INSTALL_INTERFACE:include>)
INSTALL(TARGETS ${PROJECT_NAME} EXPORT ${TARGETS_EXPORT_NAME} DESTINATION lib)
# ----------------------------------------------------
# --- INCLUDE ----------------------------------------
# ----------------------------------------------------
......@@ -163,37 +177,38 @@ SET(${PROJECT_NAME}_SOURCES
src/version.cpp
)
ADD_LIBRARY(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_SOURCES} ${${PROJECT_NAME}_HEADERS})
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME}
ADD_LIBRARY(${PY_PROJECT_NAME} SHARED ${${PROJECT_NAME}_SOURCES} ${${PROJECT_NAME}_HEADERS})
TARGET_INCLUDE_DIRECTORIES(${PY_PROJECT_NAME}
SYSTEM PUBLIC
${Boost_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR}
${PYTHON_INCLUDE_DIR}
${NUMPY_INCLUDE_DIRS}
INTERFACE
#$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include> # TODO: do we really need that ?
$<INSTALL_INTERFACE:include>)
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SUFFIX ${PYTHON_EXT_SUFFIX})
IF(SUFFIX_SO_VERSION)
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION})
SET_TARGET_PROPERTIES(${PY_PROJECT_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION})
ENDIF(SUFFIX_SO_VERSION)
IF(NOT WIN32)
TARGET_COMPILE_OPTIONS(${PROJECT_NAME} PRIVATE $<$<CXX_COMPILER_ID:MSVC>:-bigobj> "-Wno-conversion")
TARGET_COMPILE_OPTIONS(${PY_PROJECT_NAME} PRIVATE $<$<CXX_COMPILER_ID:MSVC>:-bigobj> "-Wno-conversion")
ELSE()
TARGET_COMPILE_OPTIONS(${PROJECT_NAME} PRIVATE $<$<CXX_COMPILER_ID:MSVC>:-bigobj>)
TARGET_COMPILE_OPTIONS(${PY_PROJECT_NAME} PRIVATE $<$<CXX_COMPILER_ID:MSVC>:-bigobj>)
ENDIF()
TARGET_LINK_BOOST_PYTHON(${PROJECT_NAME} PUBLIC)
INSTALL(TARGETS ${PROJECT_NAME}
EXPORT ${TARGETS_EXPORT_NAME}
TARGET_LINK_BOOST_PYTHON(${PY_PROJECT_NAME} PUBLIC)
INSTALL(TARGETS ${PY_PROJECT_NAME}
EXPORT ${TARGETS_EXPORT_PY_NAME}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
PROJECT_INSTALL_COMPONENT(${PY_PROJECT_NAME})
ADD_HEADER_GROUP(${PROJECT_NAME}_HEADERS)
ADD_SOURCE_GROUP(${PROJECT_NAME}_SOURCES)
......@@ -211,8 +226,3 @@ ADD_SUBDIRECTORY(python)
# --- UNIT TEST --------------------------------------
# ----------------------------------------------------
ADD_SUBDIRECTORY(unittest)
PKG_CONFIG_APPEND_LIBS(${PROJECT_NAME})
PKG_CONFIG_APPEND_CFLAGS("-I${PYTHON_INCLUDE_DIRS}")
PKG_CONFIG_APPEND_CFLAGS("-I${NUMPY_INCLUDE_DIRS}")
PKG_CONFIG_APPEND_BOOST_LIBS(${BOOST_COMPONENTS})
Subproject commit e542b72a3435ea50654132c268d459f0a29fe3b6
Subproject commit 178441159f781ff6199af9ead4b12c4ed66a25bf
......@@ -8,7 +8,7 @@ SET_TARGET_PROPERTIES(python PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD True)
ADD_LIBRARY(${PYWRAP} SHARED main.cpp)
ADD_DEPENDENCIES(python ${PYWRAP})
TARGET_LINK_LIBRARIES(${PYWRAP} PUBLIC ${PROJECT_NAME})
TARGET_LINK_LIBRARIES(${PYWRAP} PUBLIC ${PY_PROJECT_NAME})
# BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS spews conversion warnings from int to long unsigned int.
# Unfortunately, using literals does not work in a macro. As such, this turns them off for the entire wrapper:
IF(NOT WIN32)
......
......@@ -12,7 +12,7 @@ MACRO(ADD_LIB_UNIT_TEST test)
ADD_LIBRARY(${test} SHARED EXCLUDE_FROM_ALL ${test})
ENDIF(BUILD_TESTING)
TARGET_LINK_LIBRARIES(${test} PUBLIC ${PROJECT_NAME})
TARGET_LINK_LIBRARIES(${test} PUBLIC ${PY_PROJECT_NAME})
SET_TARGET_PROPERTIES(${test} PROPERTIES PREFIX "")
SET_TARGET_PROPERTIES(${test} PROPERTIES SUFFIX ${PYTHON_EXT_SUFFIX})
......
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