Commit 02cc0fa0 by Maarten L. Hekkelman

Using CTest

Create docs/xml directory
parent 41f343c2
...@@ -36,6 +36,7 @@ include(CheckLibraryExists) ...@@ -36,6 +36,7 @@ include(CheckLibraryExists)
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
include(CheckCXXSourceCompiles) include(CheckCXXSourceCompiles)
include(GenerateExportHeader) include(GenerateExportHeader)
include(CTest)
set(CXX_EXTENSIONS OFF) set(CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
...@@ -83,8 +84,6 @@ else() ...@@ -83,8 +84,6 @@ else()
endif() endif()
# Unit tests # Unit tests
option(ENABLE_TESTING "Build test exectuables" OFF)
if(BUILD_FOR_CCP4) if(BUILD_FOR_CCP4)
if("$ENV{CCP4}" STREQUAL "" OR NOT EXISTS $ENV{CCP4}) if("$ENV{CCP4}" STREQUAL "" OR NOT EXISTS $ENV{CCP4})
message(FATAL_ERROR "A CCP4 built was requested but CCP4 was not sourced") message(FATAL_ERROR "A CCP4 built was requested but CCP4 was not sourced")
...@@ -411,7 +410,7 @@ write_basic_package_version_file( ...@@ -411,7 +410,7 @@ write_basic_package_version_file(
COMPATIBILITY AnyNewerVersion COMPATIBILITY AnyNewerVersion
) )
if(ENABLE_TESTING) if(BUILD_TESTING)
enable_testing() enable_testing()
find_package(Boost REQUIRED) find_package(Boost REQUIRED)
......
...@@ -108,13 +108,9 @@ This checks out the source code from github, creates a new directory ...@@ -108,13 +108,9 @@ This checks out the source code from github, creates a new directory
where cmake stores its files. Run a configure, build the code and then where cmake stores its files. Run a configure, build the code and then
it installs the library and auxiliary files. it installs the library and auxiliary files.
If you want to run the tests before installing, you should add `-DENABLE_TESTING=ON` Tests are created by default, and to test the code you can run:
to the first cmake command. So that would be:
```console ```console
git clone https://github.com/PDB-REDO/libcifpp.git --recurse-submodules
cd libcifpp
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=$HOME/.local -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTING=ON
cmake --build build cmake --build build
ctest --test-dir build ctest --test-dir build
``` ```
...@@ -7,18 +7,21 @@ set(CIFPP_PUBLIC_HEADER_DIR ${PROJECT_SOURCE_DIR}/include) ...@@ -7,18 +7,21 @@ set(CIFPP_PUBLIC_HEADER_DIR ${PROJECT_SOURCE_DIR}/include)
file(GLOB_RECURSE CIFPP_PUBLIC_HEADERS ${CIFPP_PUBLIC_HEADER_DIR}/*.hpp) file(GLOB_RECURSE CIFPP_PUBLIC_HEADERS ${CIFPP_PUBLIC_HEADER_DIR}/*.hpp)
set(DOXYGEN_INPUT_DIR ${CIFPP_PUBLIC_HEADER_DIR}) set(DOXYGEN_INPUT_DIR ${CIFPP_PUBLIC_HEADER_DIR})
set(DOXYGEN_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(DOXYGEN_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/xml)
set(DOXYGEN_INDEX_FILE ${DOXYGEN_OUTPUT_DIR}/xml/index.xml) set(DOXYGEN_INDEX_FILE ${DOXYGEN_OUTPUT_DIR}/index.xml)
set(DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in) set(DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
set(DOXYFILE_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) set(DOXYFILE_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
#Replace variables inside @@ with the current values #Replace variables inside @@ with the current values
configure_file(${DOXYFILE_IN} ${DOXYFILE_OUT} @ONLY) configure_file(${DOXYFILE_IN} ${DOXYFILE_OUT} @ONLY)
file(MAKE_DIRECTORY ${DOXYGEN_OUTPUT_DIR}/xml) #Doxygen won't create this for us add_custom_command(
OUTPUT ${DOXYGEN_OUTPUT_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory ${DOXYGEN_OUTPUT_DIR})
add_custom_command(OUTPUT ${DOXYGEN_INDEX_FILE} add_custom_command(OUTPUT ${DOXYGEN_INDEX_FILE}
BYPRODUCTS ${DOXYGEN_OUTPUT_DIR}/xml BYPRODUCTS ${DOXYGEN_OUTPUT_DIR}
DEPENDS ${CIFPP_PUBLIC_HEADERS} ${DOXYFILE_OUT} DEPENDS ${DOXYGEN_OUTPUT_DIR} ${CIFPP_PUBLIC_HEADERS} ${DOXYFILE_OUT}
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE_OUT} COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE_OUT}
MAIN_DEPENDENCY ${DOXYFILE_OUT} ${DOXYFILE_IN} MAIN_DEPENDENCY ${DOXYFILE_OUT} ${DOXYFILE_IN}
COMMENT "Generating docs") COMMENT "Generating docs")
...@@ -32,7 +35,7 @@ set(SPHINX_BUILD ${CMAKE_CURRENT_BINARY_DIR}/sphinx) ...@@ -32,7 +35,7 @@ set(SPHINX_BUILD ${CMAKE_CURRENT_BINARY_DIR}/sphinx)
add_custom_target(Sphinx ALL add_custom_target(Sphinx ALL
COMMAND ${SPHINX_EXECUTABLE} -b html COMMAND ${SPHINX_EXECUTABLE} -b html
-Dbreathe_projects.${PROJECT_NAME}=${DOXYGEN_OUTPUT_DIR}/xml -Dbreathe_projects.${PROJECT_NAME}=${DOXYGEN_OUTPUT_DIR}
${SPHINX_SOURCE} ${SPHINX_BUILD} ${SPHINX_SOURCE} ${SPHINX_BUILD}
DEPENDS ${DOXYGEN_INDEX_FILE} DEPENDS ${DOXYGEN_INDEX_FILE}
BYPRODUCTS ${CMAKE_CURRENT_SOURCE_DIR}/api BYPRODUCTS ${CMAKE_CURRENT_SOURCE_DIR}/api
......
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