Skip to content

Commit

Permalink
Improved component handling + reduced test/cmake to min cmake version…
Browse files Browse the repository at this point in the history
… 3.5

- fixed move installation
  • Loading branch information
jrmadsen committed Jul 31, 2020
1 parent dac0702 commit 9be5c38
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 21 deletions.
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
34 changes: 21 additions & 13 deletions make/likwid-config.cmake
Original file line number Diff line number Diff line change
@@ -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()

Expand All @@ -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
Expand Down Expand Up @@ -124,22 +136,19 @@ 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)
if(LIKWID_NVIDIA_INTERFACE)
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()

Expand All @@ -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)

#------------------------------------------------------------------------------#
Expand Down
25 changes: 22 additions & 3 deletions test/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 9be5c38

Please sign in to comment.