@@ -48,6 +48,10 @@ set(CMAKE_CXX_STANDARD 11)
4848set (CMAKE_CXX_STANDARD_REQUIRED TRUE )
4949set (CMAKE_CXX_EXTENSIONS OFF )
5050
51+ # Packages to include.
52+ include (GNUInstallDirs )
53+ include (CMakePackageConfigHelpers )
54+
5155# Enable IDE folders for targets.
5256set_property (GLOBAL PROPERTY USE_FOLDERS ON )
5357
@@ -747,14 +751,52 @@ else()
747751 # Remove duplicates in the addon list, if they exist.
748752 list (REMOVE_DUPLICATES ENABLE_ADDON)
749753 message (" Configuring with addons:" )
754+ # Check compiler version requirements for each addon
755+ set (FILTERED_ADDON_LIST "" )
750756 foreach (ADDON ${ENABLE_ADDON} )
751757 message (" ${ADDON} " )
752758 if (NOT (EXISTS ${PROJECT_SOURCE_DIR } /addon/${ADDON} ))
753759 message (FATAL_ERROR "Requested addon sub-directory does not exist! Cannot continue. \
754760 *** Please verify addon existence and name." )
755761 endif ()
762+
763+ # Check if this is aocl_gemm addon and verify compiler version
764+ if ("${ADDON} " STREQUAL "aocl_gemm" )
765+ if ("${CMAKE_C_COMPILER_ID } " STREQUAL "GNU" )
766+ # aocl_gemm addon (LPGEMM) requires GCC 11.2 or newer
767+ # due to AVX-512 intrinsics and optimization requirements.
768+ if (CMAKE_C_COMPILER_VERSION VERSION_LESS 11.2.0)
769+ message (WARNING "aocl_gemm addon requires GCC 11.2 or newer." )
770+ message (WARNING "Current GCC version is ${CMAKE_C_COMPILER_VERSION } ." )
771+ message (WARNING "Skipping aocl_gemm addon." )
772+ continue ()
773+ endif ()
774+ elseif ("${CMAKE_C_COMPILER_ID } " MATCHES "Clang" )
775+ # aocl_gemm addon (LPGEMM) requires Clang 12.0 or newer
776+ # due to AVX-512 intrinsics and C++17 requirements.
777+ if (CMAKE_C_COMPILER_VERSION VERSION_LESS 12.0.0)
778+ message (WARNING "aocl_gemm addon requires Clang 12.0 or newer." )
779+ message (WARNING "Current Clang version is ${CMAKE_C_COMPILER_VERSION } ." )
780+ message (WARNING "Skipping aocl_gemm addon." )
781+ continue ()
782+ endif ()
783+ endif ()
784+ endif ()
785+ list (APPEND FILTERED_ADDON_LIST ${ADDON} )
756786 endforeach ()
757- set (ENABLE_ADDONS_01 1)
787+
788+ # Update ENABLE_ADDON with filtered list
789+ set (ENABLE_ADDON ${FILTERED_ADDON_LIST} )
790+ # Also update the cache to reflect the filtered list
791+ set (ENABLE_ADDON ${FILTERED_ADDON_LIST} CACHE STRING "Filtered addon list" FORCE )
792+
793+ list (LENGTH ENABLE_ADDON addon_count)
794+ if (addon_count GREATER 0)
795+ set (ENABLE_ADDONS_01 1)
796+ else ()
797+ message (" All addons were filtered out due to compatibility issues." )
798+ set (ENABLE_ADDONS_01 0)
799+ endif ()
758800endif ()
759801cmake_print_variables (ENABLE_SANDBOX )
760802if (ENABLE_SANDBOX STREQUAL "" )
@@ -1332,69 +1374,133 @@ if(NOT WIN32)
13321374 @ONLY
13331375 )
13341376endif ()
1335- include (GNUInstallDirs )
13361377
13371378if (BUILD_SHARED_LIBS )
1338- # Build shared library.
1339- add_library (libblis-shared SHARED ${OBJECT_LIBRARIES} )
1340- target_link_libraries (libblis-shared PRIVATE ${LDFLAGS} )
1341- set_target_properties (libblis-shared PROPERTIES LINKER_LANGUAGE C VERSION ${VERSION} SOVERSION ${SO_VERSION_MAJOR} )
1342- set_target_properties (libblis-shared PROPERTIES POSITION_INDEPENDENT_CODE ON )
1343- if (THREADING_MODEL STREQUAL "openmp" )
1344- if ((NOT ${OpenMP_libomp_LIBRARY} STREQUAL "" ) AND (NOT WIN32 ))
1345- target_link_libraries (libblis-shared PRIVATE ${OpenMP_libomp_LIBRARY} )
1346- else ()
1347- target_link_libraries (libblis-shared PRIVATE OpenMP::OpenMP_C )
1348- endif ()
1349- endif ()
1350- add_dependencies (libblis-shared flat-header )
1351- if (ENABLE_CBLAS)
1352- add_dependencies (libblis-shared flat-cblas-header )
1353- endif ()
1354- # Add headers as a property to the library.
1355- set_target_properties (libblis-shared PROPERTIES PUBLIC_HEADER "${BLIS_PUBLIC_HEADERS} " )
1356- set_target_properties (libblis-shared PROPERTIES OUTPUT_NAME ${LIBBLIS_SHARED} )
1357- # Install targets for shared.
1358- install (TARGETS libblis-shared LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX } /lib
1359- ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX } /lib
1360- RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX } /lib
1361- PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_PREFIX } /include)
1362- set (libblis_depends libblis-shared)
1379+ # Build shared library with proper target name
1380+ add_library (blis_shared SHARED ${OBJECT_LIBRARIES} )
1381+ set_target_properties (blis_shared PROPERTIES
1382+ VERSION ${VERSION}
1383+ SOVERSION ${SO_VERSION_MAJOR}
1384+ OUTPUT_NAME ${LIBBLIS_SHARED}
1385+ )
13631386endif ()
13641387if (BUILD_STATIC_LIBS OR NOT BUILD_SHARED_LIBS )
1365- # Build static library.
1366- add_library (libblis-static STATIC ${OBJECT_LIBRARIES} )
1367- set_target_properties (libblis-static PROPERTIES LINKER_LANGUAGE C)
1368- # Setting this for static to fix issues where test programs built with gcc 9.4.0 fail to link versions of BLIS build with AOCC 4.0.0.
1369- set_target_properties (libblis-static PROPERTIES POSITION_INDEPENDENT_CODE ON )
1370- add_dependencies (libblis-static flat-header )
1371- if (ENABLE_CBLAS)
1372- add_dependencies (libblis-static flat-cblas-header )
1388+ # Build static library with proper target name.
1389+ add_library (blis_static STATIC ${OBJECT_LIBRARIES} )
1390+ set_target_properties (blis_static PROPERTIES
1391+ OUTPUT_NAME ${LIBBLIS_STATIC}
1392+ )
1393+ endif ()
1394+
1395+ # Create the main blis target that points to the preferred library type
1396+ # Priority: shared if available, otherwise static
1397+ if (BUILD_SHARED_LIBS AND TARGET blis_shared)
1398+ add_library (blis ALIAS blis_shared )
1399+ # Create the AOCL::BLIS alias pointing directly to the real target
1400+ add_library (AOCL::BLIS ALIAS blis_shared ) # Point to real target, not alias
1401+ # Create the AOCL::BLAS alias pointing directly to the real target
1402+ add_library (AOCL::BLAS ALIAS blis_shared ) # Point to real target, not alias
1403+ elseif (TARGET blis_static)
1404+ add_library (blis ALIAS blis_static )
1405+ # Create the AOCL::BLIS alias pointing directly to the real target
1406+ add_library (AOCL::BLIS ALIAS blis_static ) # Point to real target, not alias
1407+ # Create the AOCL::BLAS alias pointing directly to the real target
1408+ add_library (AOCL::BLAS ALIAS blis_static ) # Point to real target, not alias
1409+ endif ()
1410+
1411+ # Also create specific aliases for explicit usage
1412+ if (TARGET blis_shared)
1413+ add_library (AOCL::BLIS_shared ALIAS blis_shared )
1414+ # Create the AOCL::BLAS_shared alias as well
1415+ add_library (AOCL::BLAS_shared ALIAS blis_shared )
1416+ endif ()
1417+ if (TARGET blis_static)
1418+ add_library (AOCL::BLIS_static ALIAS blis_static )
1419+ # Create the AOCL::BLAS_static alias as well
1420+ add_library (AOCL::BLAS_static ALIAS blis_static )
1421+ endif ()
1422+
1423+ foreach (target IN ITEMS blis_shared blis_static)
1424+ if (TARGET ${target} )
1425+ target_include_directories (${target}
1426+ PUBLIC
1427+ $<BUILD_INTERFACE :${PROJECT_BINARY_DIR } /include /${BLIS_CONFIG_FAMILY} >
1428+ $<INSTALL_INTERFACE :${CMAKE_INSTALL_INCLUDEDIR} >
1429+ PRIVATE
1430+ $<BUILD_INTERFACE :${PROJECT_SOURCE_DIR } /frame /include >
1431+ )
1432+
1433+ add_dependencies (${target} flat-header )
1434+ if (ENABLE_CBLAS)
1435+ add_dependencies (${target} flat-cblas-header )
1436+ endif ()
1437+
1438+ target_link_libraries (${target} PUBLIC ${LDFLAGS} )
1439+
1440+ if (THREADING_MODEL STREQUAL "openmp" )
1441+ if ((NOT ${OpenMP_libomp_LIBRARY} STREQUAL "" ) AND (NOT WIN32 ))
1442+ target_link_libraries (${target} PUBLIC ${OpenMP_libomp_LIBRARY} )
1443+ else ()
1444+ target_link_libraries (${target} PUBLIC OpenMP::OpenMP_C )
1445+ endif ()
1446+ endif ()
1447+
1448+ set_target_properties (${target} PROPERTIES
1449+ LINKER_LANGUAGE C
1450+ POSITION_INDEPENDENT_CODE ON
1451+ )
13731452 endif ()
1374- # Add headers as a property to the library.
1375- set_target_properties (libblis-static PROPERTIES PUBLIC_HEADER "${BLIS_PUBLIC_HEADERS} " )
1376- set_target_properties (libblis-static PROPERTIES OUTPUT_NAME ${LIBBLIS_STATIC} )
1377- # Install targets.
1378- install (TARGETS libblis-static LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX } /lib
1379- ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX } /lib
1380- RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX } /lib
1381- PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_PREFIX } /include)
1382- list (APPEND libblis_depends libblis-static)
1453+ endforeach ()
1454+
1455+ # Installation rules
1456+ if (BUILD_SHARED_LIBS AND TARGET blis_shared)
1457+ install (TARGETS blis_shared
1458+ EXPORT blisTargets
1459+ LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX } /lib
1460+ ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX } /lib
1461+ RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX } /lib
1462+ INCLUDES DESTINATION ${CMAKE_INSTALL_PREFIX } /include
1463+ )
13831464endif ()
13841465
1466+ if ((BUILD_STATIC_LIBS OR NOT BUILD_SHARED_LIBS ) AND TARGET blis_static)
1467+ install (TARGETS blis_static
1468+ EXPORT blisTargets
1469+ LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX } /lib
1470+ ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX } /lib
1471+ RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX } /lib
1472+ INCLUDES DESTINATION ${CMAKE_INSTALL_PREFIX } /include
1473+ )
1474+ endif ()
1475+
1476+ # Install headers
1477+ install (FILES ${BLIS_PUBLIC_HEADERS}
1478+ DESTINATION ${CMAKE_INSTALL_PREFIX } /include
1479+ )
1480+
13851481if (NOT WIN32 )
13861482 # Install package-config file.
13871483 install (FILES ${CMAKE_BINARY_DIR } /${PC_OUT_FILE} DESTINATION ${CMAKE_INSTALL_PREFIX } /lib/pkgconfig)
13881484endif ()
13891485
13901486# Set libblis to the shared or static libblis depending on the option setting.
1391- if (TEST_WITH_SHARED)
1392- set (libblis_link libblis-shared)
1487+ if (TEST_WITH_SHARED AND TARGET blis_shared)
1488+ set (libblis_link blis_shared)
1489+ elseif (TARGET blis_static)
1490+ set (libblis_link blis_static)
13931491else ()
1394- set (libblis_link libblis-static )
1492+ message ( FATAL_ERROR "No suitable BLIS library target found" )
13951493endif ()
13961494
13971495# --- Primary targets ---
1496+ set (libblis_depends "" )
1497+ if (TARGET blis_shared)
1498+ list (APPEND libblis_depends blis_shared)
1499+ endif ()
1500+ if (TARGET blis_static)
1501+ list (APPEND libblis_depends blis_static)
1502+ endif ()
1503+
13981504add_custom_target (libblis DEPENDS ${libblis_depends} )
13991505add_custom_target (libs DEPENDS ${libblis} )
14001506
0 commit comments