Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make tests optional & use submodule for Heap-Layers #100

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "external/Heap-Layers"]
path = external/Heap-Layers
url = https://github.com/emeryberger/Heap-Layers.git
[submodule "external/googletest"]
path = external/googletest
url = https://github.com/google/googletest.git
27 changes: 3 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,10 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_OUTPUT_DIRECTORY}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_OUTPUT_DIRECTORY}/lib)
set(CMAKE_HEADER_OUTPUT_DIRECTORY ${CMAKE_OUTPUT_DIRECTORY}/include)


include(ExternalProject)

ExternalProject_Add(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG 3e0e32ba300ce8afe695ad3ba7e81b21b7cf237a
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-src"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-build"
INSTALL_COMMAND ""
TEST_COMMAND ""
)

ExternalProject_Add(heap_layers
GIT_REPOSITORY https://github.com/emeryberger/Heap-Layers.git
GIT_TAG a80041cc15174ab82a39bae1cd750b52955c7eef
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/heap_layers-src"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/heap_layers-build"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)

#Create configure options
option(DEBUG "Build with debugging symbols" OFF) #replace with CMAKE_BUILD_TYPE?
option(OPTIMIZE " Build with optimizations" ON) #replace with CMAKE_BUILD_TYPE?
option(OPTIMIZE "Build with optimizations" ON) #replace with CMAKE_BUILD_TYPE?
option(BUILD_TESTS "Build with tests" OFF)
option(GCOV "Build with gcov profiling support" OFF)
option(CLANGCOV "Build with clangcov profiling support" OFF)
set(RANDOMIZATION "1" CACHE STRING "0: no randomization. 1: freelist init only. 2: freelist init + free fastpath")
Expand Down Expand Up @@ -102,6 +80,7 @@ else()
endif()

if (${GCOV} AND GCC)
set(BUILD_TESTS ON)
find_program(GCOVp gcov)
if (GCOVp)
add_definitions(--coverage)
Expand Down
1 change: 1 addition & 0 deletions external/Heap-Layers
Submodule Heap-Layers added at 27c72f
18 changes: 8 additions & 10 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#Include current folder to guarantee headers are found by files
include_directories(./)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/../heap_layers-src)
# include_directories(./vendor/Heap-Layers)
include_directories(${CMAKE_SOURCE_DIR}/external/Heap-Layers)

#Create a common set of source files
set(common_src
Expand All @@ -23,6 +22,9 @@ set(mesh_src
add_library(mesh SHARED ${mesh_src})
target_link_libraries(mesh PRIVATE -pthread -ldl)

if(${BUILD_TESTS})
find_package(GTest 1.0 REQUIRED)

#Create a set of source files for the unit tests
set(unit_src
${common_src}
Expand All @@ -39,17 +41,12 @@ set(unit_src
add_executable(unit.test ${unit_src})
target_link_libraries(unit.test PRIVATE -ldl -pthread )

set(GTEST_DIR ${CMAKE_CURRENT_BINARY_DIR}/../googletest-src/googletest)

ExternalProject_Get_Property(googletest binary_dir)
set(GTEST_LIBRARY_PATH ${binary_dir}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest.a)
target_link_libraries(unit.test PRIVATE ${GTEST_LIBRARY_PATH})
target_link_libraries(unit.test PRIVATE GTest::GTest)

set(GTEST_MAIN_LIBRARY_PATH ${binary_dir}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main.a)
target_link_libraries(unit.test PRIVATE ${GTEST_MAIN_LIBRARY_PATH})
target_link_libraries(unit.test PRIVATE GTest::Main)

#Include header file paths to the unit tests
target_include_directories(unit.test SYSTEM PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/../googletest-src/googletest/include)
target_include_directories(unit.test SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/external/googletest/include)

#Set specific compiler flags for the unit tests
target_compile_definitions(unit.test PRIVATE -DGTEST_HAS_PTHREAD=1)
Expand Down Expand Up @@ -83,3 +80,4 @@ if(${CLANGCOV})
# WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/coverage/
# DEPENDS unit.test)
endif()
endif()