From 9be5c38094f04b361e160ceb948ce0f4d4a887af Mon Sep 17 00:00:00 2001 From: "Jonathan R. Madsen" Date: Fri, 31 Jul 2020 07:02:59 -0700 Subject: [PATCH] Improved component handling + reduced test/cmake to min cmake version 3.5 - fixed move installation --- Makefile | 13 ++++++++----- make/likwid-config.cmake | 34 +++++++++++++++++++++------------- test/cmake/CMakeLists.txt | 25 ++++++++++++++++++++++--- 3 files changed, 51 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 925323bf1..f5deef066 100644 --- a/Makefile +++ b/Makefile @@ -216,8 +216,8 @@ $(DYNAMIC_TARGET_LIB): $(BUILD_DIR) $(PERFMONHEADERS) $(OBJ) $(TARGET_HWLOC_LIB) @sed -e s+'@PREFIX@'+$(INSTALLED_PREFIX)+g \ -e s+'@NVIDIA_INTERFACE@'+$(NVIDIA_INTERFACE)+g \ -e s+'@FORTRAN_INTERFACE@'+$(FORTRAN_INTERFACE)+g \ - -e s+'@LIBPREFIX@'+$(LIBPREFIX)+g \ - -e s+'@BINPREFIX@'+$(BINPREFIX)+g \ + -e s+'@LIBPREFIX@'+$(INSTALLED_LIBPREFIX)+g \ + -e s+'@BINPREFIX@'+$(INSTALLED_BINPREFIX)+g \ make/likwid-config.cmake > likwid-config.cmake $(DAEMON_TARGET): $(SRC_DIR)/access-daemon/accessDaemon.c @@ -592,9 +592,12 @@ move: move_daemon move_freq move_appdaemon @chmod 755 $(LIKWIDFILTERPATH) @cp -f $(abspath $(PREFIX)/share/likwid/filter)/* $(LIKWIDFILTERPATH) @chmod 755 $(LIKWIDFILTERPATH)/* - @mkdir -p $(INSTALLED_LIBPREFIX)/cmake/likwid - @chmod 755 $(INSTALLED_LIBPREFIX)/cmake/likwid - @install -m 644 $(LIBPREFIX)/likwid-config.cmake $(INSTALLED_LIBPREFIX)/share/likwid + @echo "===> MOVE cmake from $(abspath $(PREFIX)/share/likwid) to $(INSTALLED_PREFIX)/share/likwid" + @mkdir -p $(INSTALLED_PREFIX)/share/likwid + @chmod 755 $(INSTALLED_PREFIX)/share/likwid + @sed -e s+'\(# @MOVE_LIKWID_INSTALL@\)'+"set(_DEFAULT_PREFIXES $(INSTALLED_PREFIX) $(INSTALLED_LIBPREFIX) $(INSTALLED_BINPREFIX))\n\1"+g \ + $(PREFIX)/share/likwid/likwid-config.cmake > $(INSTALLED_PREFIX)/share/likwid/likwid-config.cmake + @chmod 644 $(INSTALLED_PREFIX)/share/likwid/likwid-config.cmake uninstall: uninstall_daemon uninstall_freq uninstall_appdaemon @echo "===> REMOVING applications from $(PREFIX)/bin" diff --git a/make/likwid-config.cmake b/make/likwid-config.cmake index 81e280f27..e40077d8e 100644 --- a/make/likwid-config.cmake +++ b/make/likwid-config.cmake @@ -1,9 +1,9 @@ # legacy variables set(LIKWID_INCLUDES @PREFIX@/include) -set(LIKWID_LIBRARIES @PREFIX@/lib/liblikwid.so -llikwid) # uses IN_LIST so return if less than 3.3.2 if(CMAKE_VERSION VERSION_LESS 3.3.2) + set(LIKWID_LIBRARIES @PREFIX@/lib/liblikwid.so -llikwid) return() endif() @@ -15,13 +15,25 @@ cmake_policy(SET CMP0057 NEW) include(FindPackageHandleStandardArgs) # variables configured during install -set(LIKWID_ROOT_DIR @PREFIX@ CACHE PATH "Path to LIKWID installation") -set(LIKWID_NVIDIA_INTERFACE @NVIDIA_INTERFACE@) -set(LIKWID_FORTRAN_INTERFACE @FORTRAN_INTERFACE@) +set(_DEFAULT_PREFIXES @PREFIX@ @LIBPREFIX@ @BINPREFIX@) + +# do not change MOVE_LIKWID_INSTALL line, used when +# moving installation (override above defaults) + +# @MOVE_LIKWID_INSTALL@ -set(_LIKWID_PATH_HINTS @PREFIX@ @LIBPREFIX@ @BINPREFIX@) +list(GET _DEFAULT_PREFIXES 0 _PREFIX) +list(GET _DEFAULT_PREFIXES 1 _LIBPREFIX) +list(GET _DEFAULT_PREFIXES 2 _BINPREFIX) + +set(LIKWID_ROOT_DIR ${_PREFIX} CACHE PATH "Path to LIKWID installation") +set(_LIKWID_PATH_HINTS ${LIKWID_ROOT_DIR} @LIBPREFIX@ @BINPREFIX@) set(_LIKWID_LIB_SUFFIXES lib lib64) +# relevant options +set(LIKWID_NVIDIA_INTERFACE @NVIDIA_INTERFACE@) +set(LIKWID_FORTRAN_INTERFACE @FORTRAN_INTERFACE@) + #------------------------------------------------------------------------------# # # Interface library @@ -124,12 +136,10 @@ set(LIKWID_COMPONENT_OPTIONS marker nvmarker) -message(STATUS "COMPONENTS: ${likwid_FIND_COMPONENTS}") if("marker" IN_LIST likwid_FIND_COMPONENTS) target_compile_definitions(likwid-library INTERFACE LIKWID_PERFMON) set(LIKWID_COMPILE_DEFINITIONS "-DLIKWID_PERFMON") set(likwid_marker_FOUND ON) - list(APPEND likwid_FOUND_COMPONENTS marker) endif() if("nvmarker" IN_LIST likwid_FIND_COMPONENTS) @@ -137,9 +147,8 @@ if("nvmarker" IN_LIST likwid_FIND_COMPONENTS) target_compile_definitions(likwid-library INTERFACE LIKWID_NVMON) set(LIKWID_COMPILE_DEFINITIONS "${LIKWID_COMPILE_DEFINITIONS} -DLIKWID_NVMON") set(likwid_nvmarker_FOUND ON) - list(APPEND likwid_FOUND_COMPONENTS nvmarker) elseif(likwid_FIND_REQUIRED_nvmarker) - list(APPEND _LIKWID_MISSING_COMPONENTS nvmarker) + set(likwid_nvmarker_FOUND OFF) endif() endif() @@ -164,21 +173,20 @@ foreach(_COMP ${likwid_FIND_COMPONENTS}) list(APPEND LIKWID_LIBRARIES ${LIKWID_${_COMP}_LIBRARY}) list(APPEND LIKWID_LIBRARY_DIRS ${_LIB_DIR}) list(APPEND likwid_FOUND_COMPONENTS ${_COMP}) + set(likwid_${_COMP}_FOUND ON) target_link_libraries(likwid-library INTERFACE ${LIKWID_${_COMP}_LIBRARY}) elseif(likwid_FIND_REQUIRED_${_COMP}) # only append to missing if required - list(APPEND _LIKWID_MISSING_COMPONENTS LIKWID_${_COMP}_LIBRARY) + set(likwid_${_COMP}_FOUND OFF) endif() endforeach() #------------------------------------------------------------------------------# # find package variables, e.g. LIKWID_FOUND -# if all required components were found _LIKWID_MISSING_COMPONENTS will -# be empty find_package_handle_standard_args( likwid REQUIRED_VARS - LIKWID_ROOT_DIR LIKWID_INCLUDE_DIR LIKWID_LIBRARY ${_LIKWID_MISSING_COMPONENTS} + LIKWID_ROOT_DIR LIKWID_INCLUDE_DIR LIKWID_LIBRARY HANDLE_COMPONENTS) #------------------------------------------------------------------------------# diff --git a/test/cmake/CMakeLists.txt b/test/cmake/CMakeLists.txt index de38ede9f..4fa771164 100644 --- a/test/cmake/CMakeLists.txt +++ b/test/cmake/CMakeLists.txt @@ -1,8 +1,27 @@ -cmake_minimum_required(VERSION 3.11 FATAL_ERROR) +cmake_minimum_required(VERSION 3.5 FATAL_ERROR) project(Likwid-Test LANGUAGES C) find_package(likwid REQUIRED COMPONENTS marker OPTIONAL_COMPONENTS nvmarker) -add_executable(test ${CMAKE_SOURCE_DIR}/test.c) -target_link_libraries(test PRIVATE likwid::likwid) +message(STATUS "") +message(STATUS "likwid_FOUND: ${likwid_FOUND}") + +foreach(_VAR LIKWID_INCLUDES LIKWID_LIBRARIES LIKWID_ROOT_DIR + LIKWID_NVIDIA_INTERFACE LIKWID_FORTRAN_INTERFACE + LIKWID_INCLUDE_DIR LIKWID_LIBRARY LIKWID_INCLUDE_DIRS + LIKWID_LIBRARIES LIKWID_LIBRARY_DIRS) + message(STATUS "${_VAR}: ${${_VAR}}") +endforeach() + +foreach(_VAR ${LIKWID_EXECUTABLE_OPTIONS}) + message(STATUS "LIKWID_${_VAR}_EXECUTABLE: ${LIKWID_${_VAR}_EXECUTABLE}") +endforeach() + +foreach(_VAR ${LIKWID_COMPONENT_OPTIONS}) + message(STATUS "likwid_${_VAR}_FOUND: ${likwid_${_VAR}_FOUND}") +endforeach() +message(STATUS "") + +add_executable(test_install_tree ${PROJECT_SOURCE_DIR}/test.c) +target_link_libraries(test_install_tree PRIVATE likwid::likwid)