Created
June 20, 2018 16:18
-
-
Save SjB/214ebaf2f909528e07a40ee5531edc5c to your computer and use it in GitHub Desktop.
FindCppUnit.cmake
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# - Find the native CppUnit includes and library | |
# | |
# This module defines | |
# CppUnit_FOUND, If false, do not try to use CppUnit | |
# CppUnit_INCLUDE_DIR, where to find cppunit.h, etc. | |
# CppUnit_LIBRARIES, the libraries to link against to use CppUnit | |
# CppUnit::CppUnit | |
find_package(PkgConfig QUIET) | |
pkg_check_modules(CppUnit QUIET cppunit) | |
# Include Dir | |
find_path(CppUnit_INCLUDE_DIR | |
NAMES cppunit/CompilerOutputter.h | |
HINTS | |
${CppUnit_INCLUDEDIR} | |
${CppUnit_INCLUDE_DIRS} | |
PATHS | |
~/Library/Frameworks | |
/Library/Frameworks | |
/usr | |
/usr/local | |
/opt | |
/opt/local | |
ENV CppUnit_DIR | |
PATH_SUFFIXES include "") | |
# Find the library files | |
set(CppUnit_NAMES cppunit ${CppUnit_PKGCONF_LIBRARIES} cppunit_dll ) | |
find_library(CppUnit_LIBRARY | |
NAMES ${CppUnit_NAMES} | |
HINTS | |
${CppUnit_LIBDIR} | |
${CppUnit_LIBRARY_DIRS} | |
PATHS | |
~/Library/Frameworks | |
/Library/Frameworks | |
/usr | |
/usr/local | |
/opt | |
/opt/local | |
ENV CppUnit_DIR | |
PATH_SUFFIXES lib lib/x86_64-linux-gnu) | |
include(FindPackageHandleStandardArgs) | |
find_package_handle_standard_args(CppUnit DEFAULT_MSG CppUnit_INCLUDE_DIR CppUnit_LIBRARY) | |
mark_as_advanced(CppUnit_INCLUDE_DIR CppUnit_LIBRARY) | |
if(CppUnit_FOUND) | |
set(CppUnit_INCLUDE_DIRS ${CppUnit_INCLUDE_DIR}) | |
set(CppUnit_LIBRARIES ${CppUnit_LIBRARY}) | |
endif() | |
if(CppUnit_FOUND AND NOT TARGET CppUnit::CppUnit) | |
add_library(CppUnit::CppUnit SHARED IMPORTED) | |
set_target_properties(CppUnit::CppUnit PROPERTIES | |
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" | |
IMPORTED_LOCATION "${CppUnit_LIBRARIES}" | |
INTERFACE_INCLUDE_DIRECTORIES "${CppUnit_INCLUDE_DIRS}") | |
endif() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment