From 49307a708a07f8189ea3143a4c8384fbe12d023e Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Fri, 19 May 2023 10:00:54 +0200 Subject: [PATCH] Add cmake modules for Nanos6 and Nodes --- cmake/FindNanos6.cmake | 29 +++++++++++++++++++++++++++++ cmake/FindNodes.cmake | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 cmake/FindNanos6.cmake create mode 100644 cmake/FindNodes.cmake diff --git a/cmake/FindNanos6.cmake b/cmake/FindNanos6.cmake new file mode 100644 index 0000000..67a82d9 --- /dev/null +++ b/cmake/FindNanos6.cmake @@ -0,0 +1,29 @@ +include(GNUInstallDirs) + +find_library(NANOS6_LIBRARY NAMES nanos6) +find_path(NANOS6_INCLUDE_DIR nanos6.h) +find_file(NANOS6_WRAPPER NAMES nanos6-main-wrapper.o PATH_SUFFIXES "lib") + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(Nanos6 DEFAULT_MSG + NANOS6_LIBRARY NANOS6_INCLUDE_DIR NANOS6_WRAPPER) + +if(NOT NANOS6_FOUND) + return() +endif() + +if(TARGET Nanos6::nanos6) + return() +endif() + +add_library(Nanos6::nanos6 SHARED IMPORTED) +set_target_properties(Nanos6::nanos6 PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${NANOS6_INCLUDE_DIR}" + IMPORTED_LOCATION ${NANOS6_LIBRARY}) + +add_library(Nanos6::wrapper STATIC IMPORTED) +set_target_properties(Nanos6::wrapper PROPERTIES + IMPORTED_LOCATION ${NANOS6_WRAPPER}) +target_compile_options(Nanos6::wrapper INTERFACE "-fompss-2") +target_link_libraries(Nanos6::wrapper INTERFACE Nanos6::nanos6) diff --git a/cmake/FindNodes.cmake b/cmake/FindNodes.cmake new file mode 100644 index 0000000..2011472 --- /dev/null +++ b/cmake/FindNodes.cmake @@ -0,0 +1,35 @@ +include(GNUInstallDirs) + +if(DEFINED ENV{NODES_HOME}) + set(NODES_HOME "$ENV{NODES_HOME}") +else() + message(STATUS "NODES_HOME not set, refusing to search") +endif() + +find_library(NODES_LIBRARY NAMES nodes PATHS "${NODES_HOME}/lib" NO_DEFAULT_PATH) +find_file(NODES_WRAPPER NAMES nodes-main-wrapper.o PATHS "${NODES_HOME}/lib" NO_DEFAULT_PATH) +find_path(NODES_INCLUDE_DIR nodes.h PATHS "${NODES_HOME}/include" NO_DEFAULT_PATH) + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(Nodes DEFAULT_MSG + NODES_LIBRARY NODES_INCLUDE_DIR NODES_WRAPPER) + +if(NOT NODES_FOUND) + return() +endif() + +if(NOT TARGET Nodes::nodes) + add_library(Nodes::nodes SHARED IMPORTED) + set_target_properties(Nodes::nodes PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${NODES_INCLUDE_DIR}" + IMPORTED_LOCATION ${NODES_LIBRARY}) +endif() + +if(NOT TARGET Nodes::wrapper) + add_library(Nodes::wrapper STATIC IMPORTED) + set_target_properties(Nodes::wrapper PROPERTIES + IMPORTED_LOCATION ${NODES_WRAPPER}) + target_compile_options(Nodes::wrapper INTERFACE "-fompss-2") + target_link_libraries(Nodes::wrapper INTERFACE Nodes::nodes) +endif()