diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a689cc48d..ec47dd506f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ #------------------------------------------------------------------------------# cmake_minimum_required(VERSION 3.7) -project(ADIOS VERSION 2.0.a) +project(ADIOS VERSION 2.0.0) #------------------------------------------------------------------------------# # Some boilerplate to setup nice output directories @@ -50,11 +50,24 @@ if(ADIOS_ENABLE_PIC) set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() +#------------------------------------------------------------------------------# +# Third party libraries +#------------------------------------------------------------------------------# +include(CTest) +add_subdirectory(thirdparty) + #------------------------------------------------------------------------------# # Main library source #------------------------------------------------------------------------------# add_subdirectory(source) +#------------------------------------------------------------------------------# +# Installation +#------------------------------------------------------------------------------# +install(DIRECTORY include/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + FILES_MATCHING PATTERN "*.h" +) #------------------------------------------------------------------------------# # Examples #------------------------------------------------------------------------------# @@ -66,20 +79,8 @@ endif() #------------------------------------------------------------------------------# # Testing #------------------------------------------------------------------------------# -include(CTest) -option(ADIOS_ENABLE_TESTING "Enable ADIOS Testing" ON) -set(ENABLE_TESTING ${ADIOS_ENABLE_TESTING} CACHE INTERNAL "" FORCE) -mark_as_advanced(ENABLE_TESTING) -if(ADIOS_ENABLE_TESTING) +# We have to wait until after the library is defined to enable testing +if(BUILD_TESTING) enable_testing() add_subdirectory(testing) endif() - -#------------------------------------------------------------------------------# -# Installation -#------------------------------------------------------------------------------# -install(DIRECTORY include/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - FILES_MATCHING PATTERN "*.h" -) - diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt new file mode 100644 index 0000000000..17c6380627 --- /dev/null +++ b/thirdparty/CMakeLists.txt @@ -0,0 +1,28 @@ +set(ADIOS_THIRDPARTY_DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/downloads + CACHE PATH "Download directory for third party dependencies") + +include(ExternalProject) + +# Boilerplate settings for a common external project infrastructure +set(EP_ARGS + DOWNLOAD_DIR ${ADIOS_THIRDPARTY_DOWNLOAD_DIR} + PREFIX . + SOURCE_DIR source + BINARY_DIR build + STAMP_DIR stamp + INSTALL_DIR install) + +# Use Google Test for a unit testing framework +cmake_dependent_option(ADIOS_USE_SYSTEM_GOOGLETEST + "Use a system-supplied Google Test framework" OFF + "BUILD_TESTING" OFF) +if(BUILD_TESTING) + if(NOT ADIOS_USE_SYSTEM_GOOGLETEST) + add_subdirectory(googletest) + endif() + find_package(GTest REQUIRED) + if(NOT ADIOS_USE_SYSTEM_GOOGLETEST) + add_dependencies(GTest::GTest googletest) + add_dependencies(GTest::Main googletest) + endif() +endif() diff --git a/thirdparty/googletest/CMakeLists.txt b/thirdparty/googletest/CMakeLists.txt new file mode 100644 index 0000000000..7d742ab09a --- /dev/null +++ b/thirdparty/googletest/CMakeLists.txt @@ -0,0 +1,36 @@ + +ExternalProject_Add(googletest + URL https://github.com/google/googletest/archive/release-1.8.0.zip + URL_MD5 adfafc8512ab65fd3cf7955ef0100ff5 + ${EP_ARGS} + CMAKE_ARGS + -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/install + -DCMAKE_POLICY_DEFAULT_CMP0048=OLD + -DCMAKE_POLICY_DEFAULT_CMP0063=NEW + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} + -DBUILD_GMOCK=OFF + -DBUILD_GTEST=ON + -Dgtest_build_samples=OFF + -Dgtest_build_tests=OFF + -Dgtest_hide_internal_symbols=ON + -Dgtest_disable_pthreads=OFF + -Dgtest_force_shared_crt=OFF) + +function(get_libfile var name) + if(BUILD_SHARED_LIBS) + set(${var} ${CMAKE_SHARED_LIBRARY_PREFIX}${name}${CMAKE_SHARED_LIBRARY_SUFFIX} PARENT_SCOPE) + else() + set(${var} ${CMAKE_STATIC_LIBRARY_PREFIX}${name}${CMAKE_STATIC_LIBRARY_SUFFIX} PARENT_SCOPE) + endif() +endfunction() + +get_libfile(GTEST_LIBRARY gtest) +get_libfile(GTEST_MAIN_LIBRARY gtest_main) +set(GTEST_ROOT ${CMAKE_CURRENT_BINARY_DIR}/install) +set(GTEST_INCLUDE_DIR ${GTEST_ROOT}/include + CACHE PATH "") +set(GTEST_LIBRARY ${GTEST_ROOT}/lib/${GTEST_LIBRARY} + CACHE FILEPATH "") +set(GTEST_MAIN_LIBRARY ${GTEST_ROOT}/lib/${GTEST_MAIN_LIBRARY} + CACHE FILEPATH "")