From: Martin Quinson Date: Sat, 10 Dec 2016 15:54:48 +0000 (+0100) Subject: make our FindSimGrid.cmake more visible (and improve it) X-Git-Tag: v3_14~85 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/6adb1a578c5b703f98fe5d8db7fdb5ebf2f30c84?hp=052f6846f7063b11c7f64dcd75a12b71846c4b9f make our FindSimGrid.cmake more visible (and improve it) --- diff --git a/FindSimGrid.cmake b/FindSimGrid.cmake new file mode 100644 index 0000000000..e92af15f15 --- /dev/null +++ b/FindSimGrid.cmake @@ -0,0 +1,60 @@ +# Cmake macro to search for the SimGrid library. + +# Copyright (c) 2016. The SimGrid Team (version 20161210). +# +# This file is free software; you can redistribute it and/or modify it +# under the terms of the license (GNU LGPL) which comes with this package. + +# The user can hint a path using the SimGrid_PATH option. +# +# Once done, the following will be defined: +# +# SimGrid_INCLUDE_DIR - the SimGrid include directories +# SimGrid_LIBRARY - link your simulator against it to use SimGrid +# +# Afterward, you should probably do the following: +# +# include_directories("${SimGrid_INCLUDE_DIR}" SYSTEM) +# target_link_libraries(your-simulator ${SimGrid_LIBRARY}) +# +# This could be improved in many ways (patches welcome): +# - Not finding SimGrid is fatal. But who would want to +# overcome such a desperate situation anyway? ;) +# - No way to specify a minimal version +# - No proper find_package() integration + +set(SimGrid_PATH ${SimGrid_PATH} CACHE PATH "Path to SimGrid library and include") +find_path(SimGrid_INCLUDE_DIR + NAMES simgrid_config.h + HINTS ${SimGrid_PATH}/include /usr/include /usr/local/include /opt/simgrid/include +) +find_library(SimGrid_LIBRARY + NAMES simgrid + HINTS ${SimGrid_PATH}/lib /usr/lib /usr/local/lib /opt/simgrid/lib +) +mark_as_advanced(SimGrid_INCLUDE_DIR) +mark_as_advanced(SimGrid_LIBRARY) + +if (NOT EXISTS "${SimGrid_INCLUDE_DIR}") + message(FATAL_ERROR "Unable to find SimGrid header file. Please point the SimGrid_PATH variable to the installation directory.") +endif () +if (NOT EXISTS "${SimGrid_LIBRARY}") + message(FATAL_ERROR "Unable to find SimGrid library. Please point the SimGrid_PATH variable to the installation directory.") +endif () + +# Extract the actual path +if (NOT "$SimGrid_INCLUDE_DIR" STREQUAL "${SimGrid_PATH}/include") + string(REGEX REPLACE "(.*)/include" "\\1" SimGrid_PATH "${SimGrid_INCLUDE_DIR}") +endif() + +# Extract the actual version number +file(READ "${SimGrid_INCLUDE_DIR}/simgrid_config.h" _SimGrid_CONFIG_H_CONTENTS) +set(_SimGrid_VERSION_REGEX ".*#define SIMGRID_VERSION_STRING \"SimGrid version ([^\"]*)\".*") +if ("${_SimGrid_CONFIG_H_CONTENTS}" MATCHES "${_SimGrid_VERSION_REGEX}") + string(REGEX REPLACE "${_SimGrid_VERSION_REGEX}" "\\1" SimGrid_VERSION "${_SimGrid_CONFIG_H_CONTENTS}") +endif ("${_SimGrid_CONFIG_H_CONTENTS}" MATCHES "${_SimGrid_VERSION_REGEX}") + + +message("-- SimGrid found in ${SimGrid_PATH} (version ${SimGrid_VERSION})") + + diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index e91b841fd2..9a03640437 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -998,6 +998,7 @@ set(CMAKEFILES_TXT set(CMAKE_SOURCE_FILES CMakeLists.txt + FindSimGrid.cmake tools/cmake/Tests.cmake tools/cmake/CTestConfig.cmake tools/cmake/CTestCustom.cmake @@ -1017,7 +1018,6 @@ set(CMAKE_SOURCE_FILES tools/cmake/Modules/FindNS3.cmake tools/cmake/Modules/FindPAPI.cmake tools/cmake/Modules/FindRngStream.cmake - tools/cmake/Modules/FindSimGrid.cmake tools/cmake/Modules/FindValgrind.cmake tools/cmake/Option.cmake tools/cmake/scripts/my_valgrind.pl diff --git a/tools/cmake/Modules/FindSimGrid.cmake b/tools/cmake/Modules/FindSimGrid.cmake deleted file mode 100644 index f97f859d54..0000000000 --- a/tools/cmake/Modules/FindSimGrid.cmake +++ /dev/null @@ -1,54 +0,0 @@ -#IF YOU HAVE INSTALL SIMGRID IN A SPECIAL DIRECTORY -#YOU CAN SPECIFY SIMGRID_ROOT - -# TO CALL THIS FILE USE -#set(CMAKE_MODULE_PATH -#${CMAKE_MODULE_PATH} -#${CMAKE_HOME_DIRECTORY}/tools/cmake/Modules -#) - -find_library(HAVE_SIMGRID_LIB - NAME simgrid - HINTS - $ENV{LD_LIBRARY_PATH} - $ENV{SIMGRID_ROOT} - PATH_SUFFIXES lib64 lib - PATHS - /opt - /opt/local - /opt/csw - /sw - /usr - ) - -find_program(HAVE_TESH - NAMES tesh - HINTS - $ENV{SIMGRID_ROOT} - PATH_SUFFIXES bin - PATHS - /opt - /opt/local - /opt/csw - /sw - /usr - ) - -message(STATUS "Looking for lib SimGrid") -if(HAVE_SIMGRID_LIB) - message(STATUS "Looking for lib SimGrid - found") - get_filename_component(simgrid_version ${HAVE_SIMGRID_LIB} REALPATH) - string(REPLACE "${HAVE_SIMGRID_LIB}." "" simgrid_version "${simgrid_version}") - string(REGEX MATCH "^[0-9]" SIMGRID_MAJOR_VERSION "${simgrid_version}") - string(REGEX MATCH "^[0-9].[0-9]" SIMGRID_MINOR_VERSION "${simgrid_version}") - string(REGEX MATCH "^[0-9].[0-9].[0-9]" SIMGRID_PATCH_VERSION "${simgrid_version}") - string(REGEX REPLACE "^${SIMGRID_MINOR_VERSION}." "" SIMGRID_PATCH_VERSION "${SIMGRID_PATCH_VERSION}") - string(REGEX REPLACE "^${SIMGRID_MAJOR_VERSION}." "" SIMGRID_MINOR_VERSION "${SIMGRID_MINOR_VERSION}") - message(STATUS "Simgrid version : ${SIMGRID_MAJOR_VERSION}.${SIMGRID_MINOR_VERSION}") -else() - message(STATUS "Looking for lib SimGrid - not found") -endif() - -if(HAVE_TESH) - message(STATUS "Found Tesh: ${HAVE_TESH}") -endif()