mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
Add unit test framework to CMakeLists.txt. Fix a couple of bugs found by unit tests. Change-Id: I2092a7f0570fae0f19f9e083c4837ccefcc4ca1a
58 lines
1.8 KiB
CMake
58 lines
1.8 KiB
CMake
cmake_minimum_required(VERSION 2.8)
|
|
project(ntcore)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -Wformat=2 -Wall -Wextra -Werror -pedantic -Wno-unused-parameter")
|
|
|
|
file(GLOB_RECURSE SRC_TARGET_FILES src/*.cpp)
|
|
#file(GLOB_RECURSE SRC_SHARE_FILES lib/share/*.cpp)
|
|
include_directories(include src)
|
|
add_library(ntcore STATIC ${SRC_SHARE_FILES} ${SRC_TARGET_FILES})
|
|
target_link_libraries(ntcore)
|
|
INSTALL(TARGETS ntcore ARCHIVE DESTINATION lib COMPONENT lib)
|
|
INSTALL(DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT headers)
|
|
|
|
|
|
#
|
|
#
|
|
#
|
|
|
|
# We need thread support
|
|
find_package(Threads REQUIRED)
|
|
|
|
# Enable ExternalProject CMake module
|
|
include(ExternalProject)
|
|
|
|
# Download and install GoogleMock
|
|
ExternalProject_Add(
|
|
gmock
|
|
URL https://googlemock.googlecode.com/files/gmock-1.7.0.zip
|
|
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gmock
|
|
# Disable install step
|
|
INSTALL_COMMAND ""
|
|
)
|
|
|
|
# Create a libgmock target to be used as a dependency by test programs
|
|
add_library(libgmock IMPORTED STATIC GLOBAL)
|
|
add_dependencies(libgmock gmock)
|
|
add_library(libgtest IMPORTED STATIC GLOBAL)
|
|
add_dependencies(libgtest gmock)
|
|
|
|
# Set gmock properties
|
|
ExternalProject_Get_Property(gmock source_dir binary_dir)
|
|
set_target_properties(libgmock PROPERTIES
|
|
"IMPORTED_LOCATION" "${binary_dir}/libgmock.a"
|
|
"IMPORTED_LINK_INTERFACE_LIBRARIES" "${CMAKE_THREAD_LIBS_INIT}"
|
|
# "INTERFACE_INCLUDE_DIRECTORIES" "${source_dir}/include"
|
|
)
|
|
set_target_properties(libgtest PROPERTIES
|
|
"IMPORTED_LOCATION" "${binary_dir}/gtest/libgtest.a"
|
|
"IMPORTED_LINK_INTERFACE_LIBRARIES" "${CMAKE_THREAD_LIBS_INIT}"
|
|
# "INTERFACE_INCLUDE_DIRECTORIES" "${source_dir}/include"
|
|
)
|
|
# I couldn't make it work with INTERFACE_INCLUDE_DIRECTORIES
|
|
include_directories("${source_dir}/include")
|
|
include_directories("${source_dir}/gtest/include")
|
|
|
|
add_subdirectory(test)
|
|
|