diff --git a/CMakeLists.txt b/CMakeLists.txt index e5a4af8..778a257 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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} diff --git a/interfaces/matlab/CMakeLists.txt b/interfaces/matlab/CMakeLists.txt index 42624a9..0843d55 100644 --- a/interfaces/matlab/CMakeLists.txt +++ b/interfaces/matlab/CMakeLists.txt @@ -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} diff --git a/interfaces/python/CMakeLists.txt b/interfaces/python/CMakeLists.txt index 9be3eca..bd20377 100644 --- a/interfaces/python/CMakeLists.txt +++ b/interfaces/python/CMakeLists.txt @@ -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})