Skip to content

Commit

Permalink
rename header only library and ensure ABI compatibility up to AVX512
Browse files Browse the repository at this point in the history
  • Loading branch information
RSchwan committed Apr 4, 2024
1 parent 6b9535e commit ee247c9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
22 changes: 15 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,44 +139,52 @@ if (BUILD_WITH_TEMPLATE_INSTANTIATION)
create_piqp_library(piqp SHARED)
set_target_properties(piqp PROPERTIES OUTPUT_NAME piqp)
target_compile_definitions(piqp PUBLIC PIQP_WITH_TEMPLATE_INSTANTIATION)
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
# Ensure ABI compatibility up to AVX512
target_compile_definitions(piqp PUBLIC EIGEN_MAX_ALIGN_BYTES=64)
endif ()
target_compile_options(piqp PRIVATE ${compiler_flags})
target_link_options(piqp PRIVATE ${compiler_flags})

create_piqp_library(piqp_static STATIC)
set_target_properties(piqp_static PROPERTIES OUTPUT_NAME piqpstatic)
target_compile_definitions(piqp_static PUBLIC PIQP_WITH_TEMPLATE_INSTANTIATION)
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
# Ensure ABI compatibility up to AVX512
target_compile_definitions(piqp_static PUBLIC EIGEN_MAX_ALIGN_BYTES=64)
endif ()
target_compile_options(piqp_static PRIVATE ${compiler_flags})
target_link_options(piqp_static PRIVATE ${compiler_flags})

create_piqp_library(piqp_interface INTERFACE)
create_piqp_library(piqp_header_only INTERFACE)
else ()
message(STATUS "Building without template instantiation")

create_piqp_library(piqp INTERFACE)
create_piqp_library(piqp_static INTERFACE)
create_piqp_library(piqp_interface INTERFACE)
create_piqp_library(piqp_header_only INTERFACE)
endif ()

if (BUILD_WITH_STD_OPTIONAL)
target_compile_definitions(piqp INTERFACE PIQP_STD_OPTIONAL)
target_compile_definitions(piqp_static INTERFACE PIQP_STD_OPTIONAL)
target_compile_definitions(piqp_interface INTERFACE PIQP_STD_OPTIONAL)
target_compile_definitions(piqp_header_only INTERFACE PIQP_STD_OPTIONAL)
endif ()
if (BUILD_WITH_STD_FILESYSTEM)
target_compile_definitions(piqp INTERFACE PIQP_STD_FILESYSTEM)
target_compile_definitions(piqp_static INTERFACE PIQP_STD_FILESYSTEM)
target_compile_definitions(piqp_interface INTERFACE PIQP_STD_FILESYSTEM)
target_compile_definitions(piqp_header_only INTERFACE PIQP_STD_FILESYSTEM)
endif ()

if (DEBUG_PRINTS)
target_compile_definitions(piqp INTERFACE PIQP_DEBUG_PRINT)
target_compile_definitions(piqp_static INTERFACE PIQP_DEBUG_PRINT)
target_compile_definitions(piqp_interface INTERFACE PIQP_DEBUG_PRINT)
target_compile_definitions(piqp_header_only INTERFACE PIQP_DEBUG_PRINT)
endif ()

add_library(piqp::piqp ALIAS piqp)
add_library(piqp::piqp_static ALIAS piqp_static)
add_library(piqp::piqp_interface ALIAS piqp_interface)
add_library(piqp::piqp_header_only ALIAS piqp_header_only)

if (BUILD_C_INTERFACE)
add_subdirectory(interfaces/c)
Expand Down Expand Up @@ -208,7 +216,7 @@ install(
)

install(
TARGETS piqp piqp_static piqp_interface
TARGETS piqp piqp_static piqp_header_only
EXPORT piqpTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
Expand Down
2 changes: 1 addition & 1 deletion interfaces/matlab/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ set_target_properties(piqp_instruction_set_mex PROPERTIES
target_compile_options(piqp_instruction_set_mex PRIVATE ${compiler_flags})

function(CREATE_PIQP_MATLAB_TARGET target_name COMPILE_OPTIONS)
matlab_add_mex(NAME ${target_name} SRC piqp_mex.cpp LINK_TO piqp_interface)
matlab_add_mex(NAME ${target_name} SRC piqp_mex.cpp LINK_TO piqp_header_only)
set_target_properties(${target_name} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}
Expand Down
2 changes: 1 addition & 1 deletion interfaces/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ endif()
function(CREATE_PIQP_PYTHON_TARGET target_name COMPILE_OPTIONS)
pybind11_add_module(${target_name} src/piqp_python.cpp)
target_compile_options(${target_name} PRIVATE ${COMPILE_OPTIONS})
target_link_libraries(${target_name} PRIVATE piqp_interface)
target_link_libraries(${target_name} PRIVATE piqp_header_only)
target_compile_definitions(${target_name} PRIVATE PYTHON_MODULE_NAME=${target_name})
# PIQP_VERSION_INFO is defined by setup.py and passed into the C++ code as a define (VERSION_INFO) here.
target_compile_definitions(${target_name} PRIVATE VERSION_INFO=${PIQP_VERSION_INFO})
Expand Down

0 comments on commit ee247c9

Please sign in to comment.