68 lines
1.5 KiB
CMake
Executable File
68 lines
1.5 KiB
CMake
Executable File
cmake_minimum_required(VERSION 3.10)
|
|
project(voxel_grid)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
include(CTest)
|
|
|
|
# # Check for sys/time.h
|
|
# check_include_file(sys/time.h HAVE_SYS_TIME_H)
|
|
# if (HAVE_SYS_TIME_H)
|
|
# add_definitions(-DHAVE_SYS_TIME_H)
|
|
# endif (HAVE_SYS_TIME_H)
|
|
|
|
# Include directories
|
|
include_directories(
|
|
include
|
|
${GTEST_INCLUDE_DIRS}
|
|
)
|
|
|
|
# Library
|
|
add_library(voxel_grid SHARED src/voxel_grid.cpp)
|
|
|
|
target_include_directories(voxel_grid
|
|
PUBLIC
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>
|
|
)
|
|
|
|
# Install targets
|
|
install(TARGETS voxel_grid
|
|
EXPORT voxel_gridTargets
|
|
ARCHIVE DESTINATION lib
|
|
LIBRARY DESTINATION lib
|
|
RUNTIME DESTINATION bin
|
|
INCLUDES DESTINATION include
|
|
)
|
|
|
|
# Install headers
|
|
install(DIRECTORY include/${PROJECT_NAME}/
|
|
DESTINATION include/${PROJECT_NAME}
|
|
)
|
|
|
|
install(EXPORT voxel_gridTargets
|
|
DESTINATION lib/cmake/voxel_grid)
|
|
|
|
|
|
# Testing
|
|
enable_testing()
|
|
|
|
# Find Google Test
|
|
find_package(GTest QUIET)
|
|
if(GTest_FOUND OR GTEST_FOUND)
|
|
# Find pthread (required for GTest)
|
|
find_package(Threads REQUIRED)
|
|
|
|
include_directories(${GTEST_INCLUDE_DIRS})
|
|
add_executable(voxel_grid_tests test/voxel_grid_tests.cpp)
|
|
target_link_libraries(voxel_grid_tests
|
|
voxel_grid
|
|
${GTEST_LIBRARIES}
|
|
Threads::Threads
|
|
)
|
|
add_test(NAME voxel_grid_tests COMMAND voxel_grid_tests)
|
|
else()
|
|
message(STATUS "Google Test not found. Tests will not be built.")
|
|
endif()
|