Commit cff411a2 authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

[CMake] Exports

parent a59f7a19
# Copyright (C) 2010 Florent Lamiraux, Thomas Moulard, JRL, CNRS/AIST.
# Copyright (C) 2010, 2020 Florent Lamiraux, Thomas Moulard, Guilhem Saurel, JRL, CNRS/AIST, LAAS-CNRS
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -13,8 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Requires at least CMake 2.6 to configure the package.
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
SET(PROJECT_NAME hpp-util)
SET(PROJECT_DESCRIPTION "Debugging tools for the HPP project.")
......@@ -24,14 +23,17 @@ INCLUDE(cmake/hpp.cmake)
INCLUDE(cmake/boost.cmake)
SET(CXX_DISABLE_WERROR 1)
SET(PROJECT_USE_CMAKE_EXPORT TRUE)
COMPUTE_PROJECT_ARGS(PROJECT_ARGS LANGUAGES CXX)
COMPUTE_PROJECT_ARGS(PROJECT_ARGS LANGUAGES CXX C)
PROJECT(${PROJECT_NAME} ${PROJECT_ARGS})
# Search for Boost.
SET(BOOST_COMPONENTS filesystem system)
SEARCH_FOR_BOOST()
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/find-external/TinyXML)
FIND_PACKAGE(TinyXML REQUIRED)
SET(${PROJECT_NAME}_HEADERS
include/hpp/util/assertion.hh
......@@ -47,16 +49,39 @@ SET(${PROJECT_NAME}_HEADERS
include/hpp/util/parser.hh
include/hpp/util/factories/ignoretag.hh
include/hpp/util/factories/sequence.hh
)
)
# Add Boost path to include directories.
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
SET(${PROJECT_NAME}_SOURCES
src/debug.cc
src/exception.cc
src/indent.cc
src/timer.cc
src/version.cc
src/parser.cc
src/factories/sequence.cc
)
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/find-external/TinyXML)
FIND_PACKAGE(TinyXML REQUIRED)
ADD_LIBRARY(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_SOURCES} ${${PROJECT_NAME}_HEADERS})
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} PRIVATE ${TinyXML_INCLUDE_DIR} ${Boost_INCLUDE_DIRS})
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} PUBLIC $<INSTALL_INTERFACE:include>)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${TinyXML_LIBRARY} ${Boost_LIBRARIES})
# Check for unistd.h presence.
INCLUDE(CheckIncludeFiles)
CHECK_INCLUDE_FILES(unistd.h HAVE_UNISTD_H)
IF(${HAVE_UNISTD_H})
TARGET_COMPILE_DEFINITIONS(${PROJECT_NAME} PRIVATE -DHAVE_UNISTD_H)
ENDIF(${HAVE_UNISTD_H})
# Define logging directory location.
TARGET_COMPILE_DEFINITIONS(${PROJECT_NAME} PRIVATE -DHPP_LOGGINGDIR="${CMAKE_INSTALL_PREFIX}/var/log")
# Set shared library version.
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION})
INSTALL(TARGETS ${PROJECT_NAME} EXPORT ${TARGETS_EXPORT_NAME} DESTINATION lib)
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(tests)
PKG_CONFIG_APPEND_LIBS("hpp-util")
PKG_CONFIG_APPEND_LIBS(${PROJECT_NAME})
PKG_CONFIG_APPEND_BOOST_LIBS(${BOOST_COMPONENTS})
Subproject commit dcec7d7b7a358f3b638b033f6be13273a0d0c6b3
Subproject commit 7ab756beff8729739c45731dfc1edb6f88d2dbc8
# Copyright (C) 2010 Florent Lamiraux, Thomas Moulard, JRL, CNRS/AIST.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Check for unistd.h presence.
INCLUDE(CheckIncludeFiles)
CHECK_INCLUDE_FILES(unistd.h HAVE_UNISTD_H)
IF(${HAVE_UNISTD_H})
ADD_DEFINITIONS(-DHAVE_UNISTD_H)
ENDIF(${HAVE_UNISTD_H})
# The shared library is being built right now.
# Required for dllimport/dllexport mechanisms in
# the generated header config.hh.
ADD_DEFINITIONS(-DBUILDING_HPP_UTIL)
# Define logging directory location.
ADD_DEFINITIONS(-DHPP_LOGGINGDIR="${CMAKE_INSTALL_PREFIX}/var/log")
# Path to boost headers
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
# Compile hpp-util library.
ADD_LIBRARY(hpp-util
SHARED
debug.cc
exception.cc
indent.cc
timer.cc
version.cc
parser.cc
factories/sequence.cc
)
# Set shared library version.
SET_TARGET_PROPERTIES(hpp-util PROPERTIES SOVERSION ${PROJECT_VERSION})
# Link against Boost libraries.
TARGET_LINK_LIBRARIES(hpp-util ${Boost_LIBRARIES})
TARGET_INCLUDE_DIRECTORIES(hpp-util PRIVATE ${TinyXML_INCLUDE_DIR})
TARGET_LINK_LIBRARIES(hpp-util ${TinyXML_LIBRARY})
INSTALL(TARGETS hpp-util DESTINATION ${CMAKE_INSTALL_LIBDIR})
......@@ -13,35 +13,25 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Path to boost headers
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
# DEFINE_TEST(NAME)
# -----------------
#
# Compile a program and add it as a test.
#
MACRO(DEFINE_TEST NAME LIB)
ADD_EXECUTABLE(${NAME} ${NAME}.cc)
TARGET_LINK_LIBRARIES(${NAME} hpp-util)
# Link against Boost.
TARGET_LINK_LIBRARIES(${NAME} ${Boost_LIBRARIES})
ADD_TEST(NAME ${NAME} COMMAND ${RUNTIME_OUTPUT_DIRECTORY}/${NAME})
MACRO(DEFINE_TEST NAME)
ADD_UNIT_TEST(${NAME} ${NAME}.cc)
TARGET_LINK_LIBRARIES(${NAME} ${PROJECT_NAME})
ENDMACRO(DEFINE_TEST)
# Define tests.
DEFINE_TEST(simple-test hpp-util)
DEFINE_TEST(assertion hpp-util)
DEFINE_TEST(exception hpp-util)
DEFINE_TEST(exception-factory hpp-util)
DEFINE_TEST(timer hpp-util)
DEFINE_TEST(simple-test)
DEFINE_TEST(assertion)
DEFINE_TEST(exception)
DEFINE_TEST(exception-factory)
DEFINE_TEST(timer)
SET(HPP_LOGGINGDIR "${CMAKE_CURRENT_BINARY_DIR}")
CONFIG_FILES(run_debug.sh)
ADD_EXECUTABLE(debug debug.cc)
TARGET_LINK_LIBRARIES(debug hpp-util ${Boost_LIBRARIES})
TARGET_LINK_LIBRARIES(debug ${PROJECT_NAME})
ADD_TEST(NAME debug COMMAND ${RUNTIME_OUTPUT_DIRECTORY}/run_debug.sh)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment