mirror of https://github.com/vitalif/grive2
117 lines
2.4 KiB
CMake
117 lines
2.4 KiB
CMake
project(libgrive)
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
|
|
|
|
find_package(OpenSSL REQUIRED)
|
|
find_package(JSONC REQUIRED)
|
|
find_package(CURL REQUIRED)
|
|
find_package(EXPAT REQUIRED)
|
|
find_package(Boost COMPONENTS filesystem system REQUIRED)
|
|
find_package(GDBM REQUIRED)
|
|
find_package(BFD)
|
|
find_package(CppUnit)
|
|
find_package(Iberty REQUIRED)
|
|
|
|
# additional headers if build unit tests
|
|
IF ( CPPUNIT_FOUND )
|
|
set( OPT_INCS ${CPPUNIT_INCLUDE_DIR} )
|
|
ENDIF ( CPPUNIT_FOUND )
|
|
|
|
# build bfd classes if libbfd is found
|
|
if ( BFD_FOUND )
|
|
set( OPT_LIBS ${DL_LIBRARY} ${BFD_LIBRARY} )
|
|
file( GLOB OPT_SRC
|
|
src/bfd/*.cc
|
|
)
|
|
add_definitions( -DHAVE_BFD )
|
|
|
|
endif ( BFD_FOUND )
|
|
|
|
include_directories(
|
|
${libgrive_SOURCE_DIR}/src
|
|
${libgrive_SOURCE_DIR}/test
|
|
${GDBM_INCLUDE_DIR}
|
|
${OPT_INCS}
|
|
)
|
|
|
|
file(GLOB DRIVE_HEADERS
|
|
${libgrive_SOURCE_DIR}/src/drive/*.hh
|
|
)
|
|
|
|
file (GLOB PROTOCOL_HEADERS
|
|
${libgrive_SOURCE_DIR}/src/protocol/*.hh
|
|
)
|
|
|
|
file (GLOB UTIL_HEADERS
|
|
${libgrive_SOURCE_DIR}/src/util/*.hh
|
|
)
|
|
|
|
file (GLOB XML_HEADERS
|
|
${libgrive_SOURCE_DIR}/src/xml/*.hh
|
|
)
|
|
|
|
file (GLOB LIBGRIVE_SRC
|
|
src/drive/*.cc
|
|
src/http/*.cc
|
|
src/protocol/*.cc
|
|
src/util/*.cc
|
|
src/xml/*.cc
|
|
)
|
|
|
|
add_definitions(
|
|
-DVERSION="${GRIVE_VERSION}"
|
|
-DTEST_DATA="${libgrive_SOURCE_DIR}/test/data/"
|
|
-DSRC_DIR="${libgrive_SOURCE_DIR}/src"
|
|
)
|
|
|
|
add_library( grive SHARED ${LIBGRIVE_SRC} ${OPT_SRC} )
|
|
|
|
target_link_libraries( grive
|
|
${CURL_LIBRARIES}
|
|
${JSONC_LIBRARY}
|
|
${OPENSSL_LIBRARIES}
|
|
${GDBM_LIBRARIES}
|
|
${Boost_LIBRARIES}
|
|
${IBERTY_LIBRARY}
|
|
${EXPAT_LIBRARY}
|
|
${OPT_LIBS}
|
|
)
|
|
|
|
set_target_properties(grive PROPERTIES
|
|
SOVERSION 0 VERSION ${GRIVE_VERSION}
|
|
)
|
|
|
|
if ( LIB_INSTALL_DIR )
|
|
else()
|
|
set ( LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib )
|
|
endif()
|
|
|
|
install(TARGETS grive LIBRARY DESTINATION ${LIB_INSTALL_DIR} )
|
|
install(FILES ${DRIVE_HEADERS} DESTINATION include/grive/drive)
|
|
install(FILES ${PROTOCOL_HEADERS} DESTINATION include/grive/protocol)
|
|
install(FILES ${UTIL_HEADERS} DESTINATION include/grive/util)
|
|
install(FILES ${XML_HEADERS} DESTINATION include/grive/xml)
|
|
|
|
IF ( CPPUNIT_FOUND )
|
|
message("-- Building unitary tests along with the library and the binary")
|
|
set( OPT_INCS ${CPPUNIT_INCLUDE_DIR} )
|
|
|
|
# list of test source files here
|
|
file(GLOB TEST_SRC
|
|
test/drive/*.cc
|
|
test/util/*.cc
|
|
test/xml/*.cc
|
|
)
|
|
|
|
add_executable( unittest
|
|
test/UnitTest.cc
|
|
${TEST_SRC}
|
|
)
|
|
|
|
target_link_libraries( unittest
|
|
grive
|
|
${CPPUNIT_LIBRARY}
|
|
)
|
|
|
|
ENDIF ( CPPUNIT_FOUND )
|