diff --git a/CMakeLists.txt b/CMakeLists.txt index 37ee53d..700a7ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,44 +2,18 @@ project(grive) cmake_minimum_required(VERSION 2.8) -include(FindOpenSSL) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") -############################################################################### -# finding cppunit -############################################################################### -find_path( CPPUNIT_INCLUDE_DIR cppunit/TestFixture.h /usr/include - /usr/local/include - ${CPPUNIT_PREFIX}/include ) -find_library( CPPUNIT_LIBRARY_DEBUG NAMES cppunit cppunit_dll - PATHS /usr/lib - /usr/lib64 - /usr/local/lib - /usr/local/lib64 - ${CPPUNIT_PREFIX}/lib - PATH_SUFFIXES debug ) +find_package(OpenSSL REQUIRED) +find_package(CppUnit REQUIRED) +find_package(JSONC REQUIRED) +find_package(CURL REQUIRED) -find_library( CPPUNIT_LIBRARY_RELEASE NAMES cppunit cppunit_dll - PATHS /usr/lib - /usr/lib64 - /usr/local/lib - /usr/local/lib64 - ${CPPUNIT_PREFIX}/lib - PATH_SUFFIXES release ) - -set( CPPUNIT_LIBRARY debug ${CPPUNIT_LIBRARY_DEBUG} - optimized ${CPPUNIT_LIBRARY_RELEASE} ) - -if ( CPPUNIT_INCLUDE_DIR AND CPPUNIT_LIBRARY ) - message( STATUS "found cppunit" ) - set( CPPUNIT_FOUND TRUE ) - set( OPT_INCS ${CPPUNIT_INCLUDE_DIR} ) -endif ( CPPUNIT_INCLUDE_DIR AND CPPUNIT_LIBRARY ) - -############################################################################### +set( OPT_INCS ${CPPUNIT_INCLUDE_DIR} ) include_directories( ${grive_SOURCE_DIR}/src - ${OPT_INCS} + ${OPT_INCS} ) add_executable( grive @@ -56,24 +30,24 @@ add_executable( grive ) target_link_libraries( grive - curl - json + ${CURL_LIBRARIES} + ${JSONC_LIBRARY} ${OPENSSL_LIBRARIES} ) -if ( CPPUNIT_FOUND ) +IF ( CPPUNIT_FOUND ) -add_executable( unittest - test/UnitTest.cc - src/util/DateTime.cc - test/util/DateTimeTest.cc - test/util/FunctionTest.cc -) + add_executable( unittest + test/UnitTest.cc + src/util/DateTime.cc + test/util/DateTimeTest.cc + test/util/FunctionTest.cc + ) -target_link_libraries( unittest - ${CPPUNIT_LIBRARY} -) + target_link_libraries( unittest + ${CPPUNIT_LIBRARY} + ) -else ( CPPUNIT_FOUND ) +ELSE ( CPPUNIT_FOUND ) message( STATUS "skip building unittest" ) -endif ( CPPUNIT_FOUND ) +ENDIF ( CPPUNIT_FOUND ) diff --git a/cmake/Modules/FindCppUnit.cmake b/cmake/Modules/FindCppUnit.cmake new file mode 100644 index 0000000..4caba06 --- /dev/null +++ b/cmake/Modules/FindCppUnit.cmake @@ -0,0 +1,32 @@ +# - Find CppUnit +# http://root.cern.ch/viewvc/trunk/cint/reflex/cmake/modules/FindCppUnit.cmake +# +# This module finds an installed CppUnit package. +# +# It sets the following variables: +# CPPUNIT_FOUND - Set to false, or undefined, if CppUnit isn't found. +# CPPUNIT_INCLUDE_DIR - The CppUnit include directory. +# CPPUNIT_LIBRARY - The CppUnit library to link against. + +FIND_PATH(CPPUNIT_INCLUDE_DIR cppunit/Test.h) +FIND_LIBRARY(CPPUNIT_LIBRARY NAMES cppunit) + +IF (CPPUNIT_INCLUDE_DIR AND CPPUNIT_LIBRARY) + SET(CPPUNIT_FOUND TRUE) +ENDIF (CPPUNIT_INCLUDE_DIR AND CPPUNIT_LIBRARY) + +IF (CPPUNIT_FOUND) + + # show which CppUnit was found only if not quiet + IF (NOT CppUnit_FIND_QUIETLY) + MESSAGE(STATUS "Found CppUnit: ${CPPUNIT_LIBRARY}") + ENDIF (NOT CppUnit_FIND_QUIETLY) + +ELSE (CPPUNIT_FOUND) + + # fatal error if CppUnit is required but not found + IF (CppUnit_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could not find CppUnit") + ENDIF (CppUnit_FIND_REQUIRED) + +ENDIF (CPPUNIT_FOUND) diff --git a/cmake/Modules/FindJSONC.cmake b/cmake/Modules/FindJSONC.cmake new file mode 100644 index 0000000..f72e8ea --- /dev/null +++ b/cmake/Modules/FindJSONC.cmake @@ -0,0 +1,30 @@ +# - Find JSON-C +# This module finds an installed JSON-C package. +# +# It sets the following variables: +# JSONC_FOUND - Set to false, or undefined, if JSON-C isn't found. +# JSONC_INCLUDE_DIR - The JSON-C include directory. +# JSONC_LIBRARY - The JSON-C library to link against. + +FIND_PATH(JSONC_INCLUDE_DIR json/json.h) +FIND_LIBRARY(JSONC_LIBRARY NAMES json) + +IF (JSONC_INCLUDE_DIR AND JSONC_LIBRARY) + SET(JSONC_FOUND TRUE) +ENDIF (JSONC_INCLUDE_DIR AND JSONC_LIBRARY) + +IF (JSONC_FOUND) + + # show which JSON-C was found only if not quiet + IF (NOT JSONC_FIND_QUIETLY) + MESSAGE(STATUS "Found JSON-C: ${JSONC_LIBRARY}") + ENDIF (NOT JSONC_FIND_QUIETLY) + +ELSE (JSONC_FOUND) + + # fatal error if JSON-C is required but not found + IF (JSONC_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could not find JSON-C") + ENDIF (JSONC_FIND_REQUIRED) + +ENDIF (JSONC_FOUND)