diff --git a/CMakeLists.txt b/CMakeLists.txt index d0812e682c71f5bf9119ba04a9b86c5d525c7eb6..16605c93fda611c927add1c50ecfe4a05008b081 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ # -# Copyright (c) 2014 CNRS -# Authors: Joseph Mirabel +# Copyright (c) 2014, 2020 CNRS +# Authors: Joseph Mirabel, Guilhem Saurel # # # This file is part of hpp-statistics @@ -17,11 +17,13 @@ # hpp-statistics If not, see # <http://www.gnu.org/licenses/>. -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +CMAKE_MINIMUM_REQUIRED(VERSION 3.1) SET(PROJECT_NAME hpp-statistics) SET(PROJECT_DESCRIPTION "Classes for doing statistics.") +SET(PROJECT_USE_CMAKE_EXPORT TRUE) + INCLUDE(cmake/hpp.cmake) COMPUTE_PROJECT_ARGS(PROJECT_ARGS LANGUAGES CXX) @@ -33,16 +35,26 @@ IF (HPP_DEBUG) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHPP_DEBUG") ENDIF() -SET (${PROJECT_NAME}_HEADERS +ADD_PROJECT_DEPENDENCY(hpp-util REQUIRED) + +SET(${PROJECT_NAME}_HEADERS include/hpp/statistics/fwd.hh include/hpp/statistics/bin.hh include/hpp/statistics/success-bin.hh include/hpp/statistics/distribution.hh ) -ADD_REQUIRED_DEPENDENCY("hpp-util >= 3.2") +SET(${PROJECT_NAME}_SOURCES + src/success-bin.cc + ) + +ADD_LIBRARY(${PROJECT_NAME} SHARED + ${${PROJECT_NAME}_SOURCES} ${${PROJECT_NAME}_HEADERS}) +TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} PUBLIC $<INSTALL_INTERFACE:include>) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} hpp-util::hpp-util) + +INSTALL(TARGETS ${PROJECT_NAME} EXPORT ${TARGETS_EXPORT_NAME} DESTINATION lib) -ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(tests) # Add dependency toward hpp-statistics library in pkg-config file. diff --git a/cmake b/cmake index 7eca9ee6c9d1c4ee20eb82272e94f9d11642053a..7ab756beff8729739c45731dfc1edb6f88d2dbc8 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit 7eca9ee6c9d1c4ee20eb82272e94f9d11642053a +Subproject commit 7ab756beff8729739c45731dfc1edb6f88d2dbc8 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt deleted file mode 100644 index f7b0f8f3a651da5f47e171d9691d384cee1040c9..0000000000000000000000000000000000000000 --- a/src/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -# -# Copyright (c) 2014 CNRS -# Authors: Joseph Mirabel -# -# -# This file is part of hpp-statistics -# hpp-statistics 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. -# -# hpp-statistics 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 -# General Lesser Public License for more details. You should have -# received a copy of the GNU Lesser General Public License along with -# hpp-statistics If not, see -# <http://www.gnu.org/licenses/>. - -SET(LIBRARY_NAME ${PROJECT_NAME}) - -ADD_LIBRARY(${LIBRARY_NAME} SHARED - success-bin.cc -) - -PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} "hpp-util") - -INSTALL(TARGETS ${LIBRARY_NAME} DESTINATION lib) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4ade95715c058eff202d579cc9d32cfaf3f94cc0..93ca6cc4198b47e7679cb98eda335b6236e10e44 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -23,20 +23,11 @@ # This macro will create a binary from `NAME.cc', link it against # Boost and add it to the test suite. # -MACRO(ADD_TESTCASE NAME GENERATED) - IF (${GENERATED} STREQUAL TRUE) - ADD_EXECUTABLE(${NAME} ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.cc) - ELSE() - ADD_EXECUTABLE(${NAME} ${NAME}.cc) - ENDIF() - ADD_TEST(${NAME} ${RUNTIME_OUTPUT_DIRECTORY}/${NAME}) - - # Link against Boost and project library. +MACRO(ADD_TESTCASE NAME) + ADD_UNIT_TEST(${NAME} ${NAME}.cc) TARGET_LINK_LIBRARIES(${NAME} ${PROJECT_NAME}) - PKG_CONFIG_USE_DEPENDENCY(${NAME} "hpp-util") - ENDMACRO(ADD_TESTCASE) -ADD_TESTCASE (test-successstatistics FALSE) -ADD_TESTCASE (test-distribution FALSE) -ADD_TESTCASE (test-statistics FALSE) +ADD_TESTCASE(test-successstatistics) +ADD_TESTCASE(test-distribution) +ADD_TESTCASE(test-statistics)