Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use FindPkgConfig for GLIB2; Remove FindGlib2 and LibFindMacros cmake…

… modules.
  • Loading branch information...
commit fdbc174b6793426d88a55e08a4a8879b9a7a0b93 1 parent 41267f0
@goWebos goWebos authored Keith Derrick committed
View
43 src/CMakeModules/FindGlib2.cmake
@@ -1,43 +0,0 @@
-# @@@LICENSE
-#
-# Copyright (c) 2010-2012 Hewlett-Packard Development Company, L.P.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# LICENSE@@@
-
-# Try to find the glib-2.0 library:
-# This will define:
-# Glib2_FOUND - system has glib-2.0
-# Glib2_INCLUDE_DIRS - the glib-2.0 include directory and any dependencies
-# Glib2_LIBRARIES - the glib-2.0 library and any dependencies
-
-include(LibFindMacros)
-
-find_program(PkgConfig NAMES pkg-config PATHS /usr/local/bin /usr/bin /bin)
-
-set(${Glib2_LIB_DIRS} "")
-
-if(PkgConfig)
- exec_program("${PkgConfig} --variable=libdir glib-2.0" OUTPUT_VARIABLE Glib2_LIB_DIRS)
-endif(PkgConfig)
-
-# Include directories
-find_path(Glib2_INCLUDE_DIRS NAMES glib.h PATH_SUFFIXES glib-2.0)
-
-find_path(Glib2_Config_INCLUDE_DIRS glibconfig.h PATH_SUFFIXES glib-2.0 glib-2.0/include lib/glib-2.0/include PATHS ${Glib2_LIB_DIRS}/glib-2.0/include)
-
-# Find the library
-find_library(Glib2_LIBRARIES NAMES glib-2.0)
-
-libfind_process(Glib2)
View
121 src/CMakeModules/LibFindMacros.cmake
@@ -1,121 +0,0 @@
-# @@@LICENSE
-#
-# Copyright (c) 2010-2012 Hewlett-Packard Development Company, L.P.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# LICENSE@@@
-
-# Fetched from http://zi.fi/cmake/Modules/LibFindMacros.cmake
-
-# Works the same as find_package, but forwards the "REQUIRED" and "QUIET" arguments
-# used for the current package. For this to work, the first parameter must be the
-# prefix of the current package, then the prefix of the new package etc, which are
-# passed to find_package.
-macro (libfind_package PREFIX)
- set (LIBFIND_PACKAGE_ARGS ${ARGN})
- if (${PREFIX}_FIND_QUIETLY)
- set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} QUIET)
- endif (${PREFIX}_FIND_QUIETLY)
- if (${PREFIX}_FIND_REQUIRED)
- set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} REQUIRED)
- endif (${PREFIX}_FIND_REQUIRED)
- find_package(${LIBFIND_PACKAGE_ARGS})
-endmacro (libfind_package)
-
-# CMake developers made the UsePkgConfig system deprecated in the same release (2.6)
-# where they added pkg_check_modules. Consequently I need to support both in my scripts
-# to avoid those deprecated warnings. Here's a helper that does just that.
-# Works identically to pkg_check_modules, except that no checks are needed prior to use.
-macro (libfind_pkg_check_modules PREFIX PKGNAME)
- if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
- include(UsePkgConfig)
- pkgconfig(${PKGNAME} ${PREFIX}_INCLUDE_DIRS ${PREFIX}_LIBRARY_DIRS ${PREFIX}_LDFLAGS ${PREFIX}_CFLAGS)
- else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
- find_package(PkgConfig)
- if (PKG_CONFIG_FOUND)
- pkg_check_modules(${PREFIX} ${PKGNAME})
- endif (PKG_CONFIG_FOUND)
- endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
-endmacro (libfind_pkg_check_modules)
-
-# Do the final processing once the paths have been detected.
-# If include dirs are needed, ${PREFIX}_PROCESS_INCLUDES should be set to contain
-# all the variables, each of which contain one include directory.
-# Ditto for ${PREFIX}_PROCESS_LIBS and library files.
-# Will set ${PREFIX}_FOUND, ${PREFIX}_INCLUDE_DIRS and ${PREFIX}_LIBRARIES.
-# Also handles errors in case library detection was required, etc.
-macro (libfind_process PREFIX)
- # Skip processing if already processed during this run
- if (NOT ${PREFIX}_FOUND)
- # Start with the assumption that the library was found
- set (${PREFIX}_FOUND TRUE)
-
- # Process all includes and set _FOUND to false if any are missing
- foreach (i ${${PREFIX}_PROCESS_INCLUDES})
- if (${i})
- set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIRS} ${${i}})
- mark_as_advanced(${i})
- else (${i})
- set (${PREFIX}_FOUND FALSE)
- endif (${i})
- endforeach (i)
-
- # Process all libraries and set _FOUND to false if any are missing
- foreach (i ${${PREFIX}_PROCESS_LIBS})
- if (${i})
- set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARIES} ${${i}})
- mark_as_advanced(${i})
- else (${i})
- set (${PREFIX}_FOUND FALSE)
- endif (${i})
- endforeach (i)
-
- # Print message and/or exit on fatal error
- if (${PREFIX}_FOUND)
- if (NOT ${PREFIX}_FIND_QUIETLY)
- message (STATUS "Found ${PREFIX} ${${PREFIX}_VERSION}:")
- message (STATUS " Headers: ${${PREFIX}_INCLUDE_DIRS}")
- message (STATUS " Libraries: ${${PREFIX}_LIBRARIES}")
- endif (NOT ${PREFIX}_FIND_QUIETLY)
- else (${PREFIX}_FOUND)
- if (${PREFIX}_FIND_REQUIRED)
- foreach (i ${${PREFIX}_PROCESS_INCLUDES} ${${PREFIX}_PROCESS_LIBS})
- message("${i}=${${i}}")
- endforeach (i)
- message (FATAL_ERROR "Required library ${PREFIX} NOT FOUND.\nInstall the library (dev version) and try again. If the library is already installed, use ccmake to set the missing variables manually.")
- endif (${PREFIX}_FIND_REQUIRED)
- endif (${PREFIX}_FOUND)
- endif (NOT ${PREFIX}_FOUND)
-endmacro (libfind_process)
-
-macro(libfind_library PREFIX basename)
- set(TMP "")
- if(MSVC80)
- set(TMP -vc80)
- endif(MSVC80)
- if(MSVC90)
- set(TMP -vc90)
- endif(MSVC90)
- set(${PREFIX}_LIBNAMES ${basename}${TMP})
- if(${ARGC} GREATER 2)
- set(${PREFIX}_LIBNAMES ${basename}${TMP}-${ARGV2})
- string(REGEX REPLACE "\\." "_" TMP ${${PREFIX}_LIBNAMES})
- set(${PREFIX}_LIBNAMES ${${PREFIX}_LIBNAMES} ${TMP})
- endif(${ARGC} GREATER 2)
- find_library(${PREFIX}_LIBRARY
- NAMES ${${PREFIX}_LIBNAMES}
- PATHS ${${PREFIX}_PKGCONF_LIBRARY_DIRS}
- )
-endmacro(libfind_library)
-
View
10 src/lib.cmake
@@ -23,7 +23,10 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/nyx_version.h.in ${PROJECT_SOU
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/nyx_config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/config/nyx_config.h)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/nyx.pc.in ${CMAKE_CURRENT_SOURCE_DIR}/config/nyx.pc @ONLY)
-find_package(Glib2 REQUIRED)
+include(FindPkgConfig)
+
+#Check that we have glib-2.0
+pkg_check_modules(GLIB2 REQUIRED glib-2.0)
nyx_component(core)
nyx_component(device)
@@ -34,8 +37,7 @@ if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${TARGET}")
endif ()
include_directories(
- ${Glib2_INCLUDE_DIRS}
- ${Glib2_Config_INCLUDE_DIRS}
+ ${GLIB2_INCLUDE_DIRS}
../include
${CMAKE_CURRENT_SOURCE_DIR}/config/
${CMAKE_CURRENT_SOURCE_DIR}/core/
@@ -48,7 +50,7 @@ add_library(nyx
)
target_link_libraries(nyx
- ${Glib2_LIBRARIES}
+ ${GLIB2_LIBRARIES}
dl
pthread
rt
Please sign in to comment.
Something went wrong with that request. Please try again.