Skip to content

Commit

Permalink
fix build process via cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
bebuch committed Nov 24, 2018
1 parent 2f409f2 commit 111cd35
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 27 deletions.
2 changes: 0 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ gcc-test:
stage: test
script:
- script/build.sh
- script/test.sh

# build and test with clang
llvm-test:
image: tuiqbv/clang-cmake:latest
stage: test
script:
- script/build.sh
- script/test.sh
33 changes: 32 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
cmake_minimum_required(VERSION 3.12.4)

# Download and unpack io_tools at configure time
configure_file(CMakeLists.txt.in io_tools-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/io_tools-download )
if(result)
message(FATAL_ERROR "CMake step for io_tools failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/io_tools-download )
if(result)
message(FATAL_ERROR "Build step for io_tools failed: ${result}")
endif()

# Prevent overriding the parent project's compiler/linker
# settings on Windows
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)

# Add io_tools directly to our build.
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/io_tools-src
${CMAKE_CURRENT_BINARY_DIR}/io_tools-build
EXCLUDE_FROM_ALL)


project(logsys VERSION 1.1.0 LANGUAGES CXX)

set(DEFAULT_BUILD_TYPE "Release")
Expand All @@ -14,11 +40,16 @@ endif()

include(GNUInstallDirs)

include_directories(SYSTEM ${io_tools_SOURCE_DIR}/include)

file(GLOB SOURCE_FILES src/*.cpp)

add_library(${PROJECT_NAME} ${SOURCE_FILES})

include_directories(../io_tools/include)
add_subdirectory(test)
enable_testing()
add_test(NAME tests COMMAND tests)

target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
Expand Down
15 changes: 15 additions & 0 deletions CMakeLists.txt.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 2.8.2)

project(io_tools-download NONE)

include(ExternalProject)
ExternalProject_Add(io_tools
GIT_REPOSITORY https://github.com/bebuch/io_tools.git
GIT_TAG master
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/io_tools-src"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/io_tools-build"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
5 changes: 4 additions & 1 deletion script/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
set -e
set -o xtrace

# Build liblogsys
# Build liblogsys and tests
mkdir -p build
cd build
cmake ..
make

# Run tests
./test/tests
15 changes: 0 additions & 15 deletions script/test.sh

This file was deleted.

9 changes: 1 addition & 8 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
cmake_minimum_required(VERSION 3.12.4)

# Download and unpack googletest at configure time
configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
Expand All @@ -26,7 +24,7 @@ add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src
EXCLUDE_FROM_ALL)


project(test)
project(tests)

# Setup testing
enable_testing()
Expand All @@ -44,8 +42,3 @@ add_executable(tests ${SOURCE_FILES})

# Link test executable against gtest & gtest_main
target_link_libraries(tests logsys gtest_main)

add_test(
NAME tests
COMMAND tests
)

0 comments on commit 111cd35

Please sign in to comment.