diff --git a/CMakeLists.txt b/CMakeLists.txt index b344fa3..68de9b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,11 +10,14 @@ endif() ## cmake module path is used for both main and tests set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/" ${CMAKE_MODULE_PATH}) +include(FindPkgConfig) + ## dependencies find_package(RT REQUIRED) find_package(M REQUIRED) -find_package(IGRAPH REQUIRED) -find_package(GLIB REQUIRED) + +pkg_check_modules(IGRAPH REQUIRED igraph) +pkg_check_modules(GLIB REQUIRED glib-2.0) ## recurse our project tree add_subdirectory(${CMAKE_SOURCE_DIR}/src/) diff --git a/cmake/FindGLIB.cmake b/cmake/FindGLIB.cmake deleted file mode 100644 index 63ce732..0000000 --- a/cmake/FindGLIB.cmake +++ /dev/null @@ -1,135 +0,0 @@ -# - Check for the presence of GLIB -# -# The following variables are set when GLIB is found: -# HAVE_GLIB = Set to true, if all components of GLIB -# have been found. -# GLIB_INCLUDES = Include path for the header files of GLIB -# GLIB_LIBRARIES = Link these to use GLIB - -## ----------------------------------------------------------------------------- -## Check for the header files - -find_path (GLIB_CORE_INCLUDES glib.h - PATHS ${CMAKE_EXTRA_INCLUDES} PATH_SUFFIXES glib-2.0/ glib-2.0/include NO_DEFAULT_PATH - ) -if(NOT GLIB_CORE_INCLUDES) - find_path (GLIB_CORE_INCLUDES glib.h - PATHS /usr/local/include /usr/include /include /sw/include /usr/lib /usr/lib64 /usr/lib/x86_64-linux-gnu/ ${CMAKE_EXTRA_INCLUDES} PATH_SUFFIXES glib-2.0/ glib-2.0/include - ) -endif(NOT GLIB_CORE_INCLUDES) - -## glibconfig is actually under the lib/ directory, so also use LIB directories -find_path (GLIB_CONFIG_INCLUDES glibconfig.h - PATHS ${CMAKE_EXTRA_INCLUDES} ${CMAKE_EXTRA_LIBRARIES} PATH_SUFFIXES glib-2.0/ glib-2.0/include NO_DEFAULT_PATH - ) -if(NOT GLIB_CONFIG_INCLUDES) - find_path (GLIB_CONFIG_INCLUDES glibconfig.h - PATHS /usr/local/include /usr/include /include /sw/include /usr/lib /usr/lib64 /usr/lib/x86_64-linux-gnu/ /usr/lib/i386-linux-gnu /usr/lib/arm-linux-gnueabihf ${CMAKE_EXTRA_INCLUDES} ${CMAKE_EXTRA_LIBRARIES} PATH_SUFFIXES glib-2.0 glib-2.0/include - ) -endif(NOT GLIB_CONFIG_INCLUDES) - -## we need both include directories -if(GLIB_CORE_INCLUDES) - if(GLIB_CONFIG_INCLUDES) - SET(GLIB_INCLUDES ${GLIB_CORE_INCLUDES} ${GLIB_CONFIG_INCLUDES}) - endif(GLIB_CONFIG_INCLUDES) -endif(GLIB_CORE_INCLUDES) - -## ----------------------------------------------------------------------------- -## Check for the library - -find_library (GLIB_CORE_LIBRARIES NAMES glib-2.0 - PATHS ${CMAKE_EXTRA_LIBRARIES} PATH_SUFFIXES glib-2.0/ NO_DEFAULT_PATH - ) -if(NOT GLIB_CORE_LIBRARIES) - find_library (GLIB_CORE_LIBRARIES NAMES glib-2.0 - PATHS /usr/local/lib /usr/lib /lib /sw/lib ${CMAKE_EXTRA_LIBRARIES} PATH_SUFFIXES glib-2.0/ - ) -endif(NOT GLIB_CORE_LIBRARIES) - -find_library (GLIB_GTHREAD_LIBRARIES NAMES gthread-2.0 - PATHS ${CMAKE_EXTRA_LIBRARIES} PATH_SUFFIXES glib-2.0/ NO_DEFAULT_PATH - ) -if(NOT GLIB_GTHREAD_LIBRARIES) - find_library (GLIB_GTHREAD_LIBRARIES NAMES gthread-2.0 - PATHS /usr/local/lib /usr/lib /lib /sw/lib ${CMAKE_EXTRA_LIBRARIES} PATH_SUFFIXES glib-2.0/ - ) -endif(NOT GLIB_GTHREAD_LIBRARIES) - -find_library (GLIB_GMODULE_LIBRARIES NAMES gmodule-2.0 - PATHS ${CMAKE_EXTRA_LIBRARIES} PATH_SUFFIXES glib-2.0/ NO_DEFAULT_PATH - ) -if(NOT GLIB_GMODULE_LIBRARIES) - find_library (GLIB_GMODULE_LIBRARIES NAMES gmodule-2.0 - PATHS /usr/local/lib /usr/lib /lib /sw/lib ${CMAKE_EXTRA_LIBRARIES} PATH_SUFFIXES glib-2.0/ - ) -endif(NOT GLIB_GMODULE_LIBRARIES) - -MARK_AS_ADVANCED(GLIB_CORE_LIBRARIES GLIB_GTHREAD_LIBRARIES GLIB_GMODULE_LIBRARIES) -SET(GLIB_LIBRARIES ${GLIB_CORE_LIBRARIES} ${GLIB_GTHREAD_LIBRARIES} ${GLIB_GMODULE_LIBRARIES}) - -## ----------------------------------------------------------------------------- -## Actions taken when all components have been found - -if (GLIB_INCLUDES AND GLIB_CORE_LIBRARIES AND GLIB_GTHREAD_LIBRARIES AND GLIB_GMODULE_LIBRARIES) - set (HAVE_GLIB TRUE) - if(EXISTS "${GLIB_CONFIG_INCLUDES}/glibconfig.h") - file(READ ${GLIB_CONFIG_INCLUDES}/glibconfig.h GLIB_VFILE) - string(REGEX MATCH "\#define GLIB_MAJOR_VERSION [0-9]+" GLIB_MAJOR_VERSION_LINE_TEST ${GLIB_VFILE}) - if(NOT ${GLIB_MAJOR_VERSION_LINE_TEST} STREQUAL "NONE") - set(GLIB_MAJOR_VERSION_LINE ${GLIB_MAJOR_VERSION_LINE_TEST}) - string(REGEX MATCHALL "([0-9]+)" GLIB_VERSION_LIST ${GLIB_MAJOR_VERSION_LINE}) - list(GET GLIB_VERSION_LIST 0 GLIB_MAJOR_VERSION) - endif() - file(READ ${GLIB_CONFIG_INCLUDES}/glibconfig.h GLIB_VFILE) - string(REGEX MATCH "\#define GLIB_MINOR_VERSION [0-9]+" GLIB_MINOR_VERSION_LINE_TEST ${GLIB_VFILE}) - if(NOT ${GLIB_MINOR_VERSION_LINE_TEST} STREQUAL "NONE") - set(GLIB_MINOR_VERSION_LINE ${GLIB_MINOR_VERSION_LINE_TEST}) - string(REGEX MATCHALL "([0-9]+)" GLIB_VERSION_LIST ${GLIB_MINOR_VERSION_LINE}) - list(GET GLIB_VERSION_LIST 0 GLIB_MINOR_VERSION) - endif() - file(READ ${GLIB_CONFIG_INCLUDES}/glibconfig.h GLIB_VFILE) - string(REGEX MATCH "\#define GLIB_MICRO_VERSION [0-9]+" GLIB_MICRO_VERSION_LINE_TEST ${GLIB_VFILE}) - if(NOT ${GLIB_MICRO_VERSION_LINE_TEST} STREQUAL "NONE") - set(GLIB_MICRO_VERSION_LINE ${GLIB_MICRO_VERSION_LINE_TEST}) - string(REGEX MATCHALL "([0-9]+)" GLIB_VERSION_LIST ${GLIB_MICRO_VERSION_LINE}) - list(GET GLIB_VERSION_LIST 0 GLIB_MICRO_VERSION) - endif() - endif() -else (GLIB_INCLUDES AND GLIB_CORE_LIBRARIES AND GLIB_GTHREAD_LIBRARIES AND GLIB_GMODULE_LIBRARIES) - if (NOT GLIB_FIND_QUIETLY) - if (NOT GLIB_INCLUDES) - message (STATUS "Unable to find GLIB header files!") - endif (NOT GLIB_INCLUDES) - if (NOT GLIB_CORE_LIBRARIES) - message (STATUS "Unable to find GLIB glib-2.0 library files!") - endif (NOT GLIB_CORE_LIBRARIES) - if (NOT GLIB_GTHREAD_LIBRARIES) - message (STATUS "Unable to find GLIB gthread-2.0 library files!") - endif (NOT GLIB_GTHREAD_LIBRARIES) - if (NOT GLIB_GMODULE_LIBRARIES) - message (STATUS "Unable to find GLIB gmodule-2.0 library files!") - endif (NOT GLIB_GMODULE_LIBRARIES) - endif (NOT GLIB_FIND_QUIETLY) -endif (GLIB_INCLUDES AND GLIB_CORE_LIBRARIES AND GLIB_GTHREAD_LIBRARIES AND GLIB_GMODULE_LIBRARIES) - -if (HAVE_GLIB) - if (NOT GLIB_FIND_QUIETLY) - message (STATUS "Found components for GLIB") - message (STATUS "GLIB_INCLUDES = ${GLIB_INCLUDES}") - message (STATUS "GLIB_LIBRARIES = ${GLIB_LIBRARIES}") - message (STATUS "GLIB_MAJOR_VERSION = ${GLIB_MAJOR_VERSION}") - message (STATUS "GLIB_MINOR_VERSION = ${GLIB_MINOR_VERSION}") - message (STATUS "GLIB_MICRO_VERSION = ${GLIB_MICRO_VERSION}") - endif (NOT GLIB_FIND_QUIETLY) -else (HAVE_GLIB) - if (GLIB_FIND_REQUIRED) - message (FATAL_ERROR "Could not find GLIB!") - endif (GLIB_FIND_REQUIRED) -endif (HAVE_GLIB) - -mark_as_advanced ( - HAVE_GLIB - GLIB_LIBRARIES - GLIB_INCLUDES - ) diff --git a/cmake/FindIGRAPH.cmake b/cmake/FindIGRAPH.cmake deleted file mode 100644 index cfeca63..0000000 --- a/cmake/FindIGRAPH.cmake +++ /dev/null @@ -1,81 +0,0 @@ -# - Check for the presence of IGRAPH -# -# The following variables are set when IGRAPH is found: -# HAVE_IGRAPH = Set to true, if all components of IGRAPH -# have been found. -# IGRAPH_INCLUDES = Include path for the header files of IGRAPH -# IGRAPH_LIBRARIES = Link these to use IGRAPH - -## ----------------------------------------------------------------------------- -## Check for the header files - -find_path (IGRAPH_INCLUDES igraph.h - PATHS ${CMAKE_EXTRA_INCLUDES} PATH_SUFFIXES igraph/ igraph/include NO_DEFAULT_PATH - ) -if(NOT IGRAPH_INCLUDES) - find_path (IGRAPH_INCLUDES igraph.h - PATHS /usr/local/include /usr/include /include /sw/include /usr/lib /usr/lib64 /usr/lib/x86_64-linux-gnu/ ${CMAKE_EXTRA_INCLUDES} PATH_SUFFIXES igraph/ igraph/include - ) -endif(NOT IGRAPH_INCLUDES) - -## ----------------------------------------------------------------------------- -## Check for the library - -find_library (IGRAPH_LIBRARIES NAMES igraph - PATHS ${CMAKE_EXTRA_LIBRARIES} PATH_SUFFIXES igraph/ NO_DEFAULT_PATH - ) -if(NOT IGRAPH_LIBRARIES) - find_library (IGRAPH_LIBRARIES NAMES igraph - PATHS /usr/local/lib /usr/lib /lib /sw/lib ${CMAKE_EXTRA_LIBRARIES} PATH_SUFFIXES igraph/ - ) -endif(NOT IGRAPH_LIBRARIES) - -## ----------------------------------------------------------------------------- -## Actions taken when all components have been found - -if (IGRAPH_INCLUDES AND IGRAPH_LIBRARIES) - set (HAVE_IGRAPH TRUE) - if(EXISTS "${IGRAPH_INCLUDES}/igraph_version.h") - set(IGRAPH_VERSION_STRING_LINE_TEST "NONE") - file(READ ${IGRAPH_INCLUDES}/igraph_version.h IGRAPH_VFILE) - string(REGEX MATCH "\#define IGRAPH_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+\"" IGRAPH_VERSION_STRING_LINE_TEST ${IGRAPH_VFILE}) - if(NOT ${IGRAPH_VERSION_STRING_LINE_TEST} STREQUAL "NONE") - set(IGRAPH_VERSION_STRING_LINE ${IGRAPH_VERSION_STRING_LINE_TEST}) - string(REGEX MATCHALL "([0-9]+)" IGRAPH_VERSION_LIST ${IGRAPH_VERSION_STRING_LINE}) - list(GET IGRAPH_VERSION_LIST 0 IGRAPH_VERSION_MAJOR_GUESS) - list(GET IGRAPH_VERSION_LIST 1 IGRAPH_VERSION_MINOR_GUESS) - list(GET IGRAPH_VERSION_LIST 2 IGRAPH_VERSION_PATCH_GUESS) - endif(NOT ${IGRAPH_VERSION_STRING_LINE_TEST} STREQUAL "NONE") - endif() -else (IGRAPH_INCLUDES AND IGRAPH_LIBRARIES) - if (NOT IGRAPH_FIND_QUIETLY) - if (NOT IGRAPH_INCLUDES) - message (STATUS "Unable to find IGRAPH header files!") - endif (NOT IGRAPH_INCLUDES) - if (NOT IGRAPH_LIBRARIES) - message (STATUS "Unable to find IGRAPH library files!") - endif (NOT IGRAPH_LIBRARIES) - endif (NOT IGRAPH_FIND_QUIETLY) -endif (IGRAPH_INCLUDES AND IGRAPH_LIBRARIES) - -if (HAVE_IGRAPH) - if (NOT IGRAPH_FIND_QUIETLY) - message (STATUS "Found components for IGRAPH") - message (STATUS "IGRAPH_INCLUDES = ${IGRAPH_INCLUDES}") - message (STATUS "IGRAPH_LIBRARIES = ${IGRAPH_LIBRARIES}") - message (STATUS "IGRAPH_VERSION_STRING_LINE = ${IGRAPH_VERSION_STRING_LINE}") - message (STATUS "IGRAPH_VERSION_MAJOR_GUESS = ${IGRAPH_VERSION_MAJOR_GUESS}") - message (STATUS "IGRAPH_VERSION_MINOR_GUESS = ${IGRAPH_VERSION_MINOR_GUESS}") - message (STATUS "IGRAPH_VERSION_PATCH_GUESS = ${IGRAPH_VERSION_PATCH_GUESS}") - endif (NOT IGRAPH_FIND_QUIETLY) -else (HAVE_IGRAPH) - if (IGRAPH_FIND_REQUIRED) - message (FATAL_ERROR "Could not find IGRAPH!") - endif (IGRAPH_FIND_REQUIRED) -endif (HAVE_IGRAPH) - -mark_as_advanced ( - HAVE_IGRAPH - IGRAPH_LIBRARIES - IGRAPH_INCLUDES - ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 73d676f..b7f9caf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,5 @@ ## build the tgen binary -include_directories(AFTER src/ ${RT_INCLUDES} ${M_INCLUDES} ${GLIB_INCLUDES} ${IGRAPH_INCLUDES}) +include_directories(AFTER src/ ${RT_INCLUDES} ${M_INCLUDES} ${GLIB_INCLUDE_DIRS} ${IGRAPH_INCLUDE_DIRS}) ## build as position-independent so it can run in Shadow add_compile_options(-std=gnu11 -fPIC -fno-omit-frame-pointer -ggdb) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ffddfa8..d0db30d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,6 +1,6 @@ ## build the mmodel test binary -include_directories(AFTER ../src/ ${M_INCLUDES} ${GLIB_INCLUDES} ${IGRAPH_INCLUDES}) +include_directories(AFTER ../src/ ${M_INCLUDES} ${GLIB_INCLUDE_DIRS} ${IGRAPH_INCLUDE_DIRS}) ## build as position-independent so it can run in Shadow add_definitions(-D_GNU_SOURCE)