Skip to content

Commit

Permalink
update travis (#8)
Browse files Browse the repository at this point in the history
* update travis

* use CPM
  • Loading branch information
TheLartians authored Apr 9, 2019
1 parent cd57d36 commit fa1d510
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ matrix:
packages:
- g++-8
env:
- MATRIX_EVAL="export CC=g++-8; export CXX=g++-8;"
- MATRIX_EVAL="export CC=gcc-8; export CXX=g++-8;"

- os: linux
compiler: clang
Expand Down
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

cmake_minimum_required (VERSION 3.0)
cmake_minimum_required (VERSION 3.5)

# ---- create project ----

Expand All @@ -24,8 +24,15 @@ endif()

# ---- dependencies ----

include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/CPM.cmake)

CPMAddPackage(
NAME LHC
GIT_REPOSITORY https://github.com/TheLartians/LHC.git
VERSION 0.3
)

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/dependencies/ctti)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/dependencies/LHC)

# ---- Header target ----

Expand Down
63 changes: 63 additions & 0 deletions cmake/CPM.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
set(_CPM_Dir "${CMAKE_CURRENT_LIST_DIR}")

include(CMakeParseArguments)
include(${_CPM_Dir}/DownloadProject.cmake)

function(CPMHasPackage)

endfunction()

function(CPMAddPackage)
set(options QUIET)

set(oneValueArgs
NAME
GIT_REPOSITORY
VERSION
GIT_TAG
BINARY_DIR
)

set(multiValueArgs "")

cmake_parse_arguments(CPM_ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

if (NOT CPM_PACKAGES)
set(CPM_PACKAGES "")
endif()

if (NOT CPM_ARGS_BINARY_DIR)
set(CPM_ARGS_BINARY_DIR ${CMAKE_BINARY_DIR}/CPM-projects/${CPM_ARGS_NAME})
endif()

if (NOT CPM_PROJECT_DIR)
set(CPM_PROJECT_DIR "${CPM_ARGS_BINARY_DIR}")
endif()

if (NOT CPM_ARGS_GIT_TAG)
set(CPM_ARGS_GIT_TAG v${CPM_ARGS_VERSION})
endif()

SET(CPM_TARGET_CMAKE_FILE "${CPM_PROJECT_DIR}")

if (${CPM_ARGS_NAME} IN_LIST CPM_PACKAGES)
message(STATUS "CPM: package ${CPM_ARGS_NAME} already added")
else()
message(STATUS "CPM: adding package ${CPM_ARGS_NAME}@${CPM_ARGS_VERSION}")
# update package data
LIST(APPEND CPM_PACKAGES ${CPM_ARGS_NAME})
# save package data
set(CPM_PACKAGES "${CPM_PACKAGES}" CACHE INTERNAL "CPM Packages")

configure_file(
"${_CPM_Dir}/CPMProject.CMakeLists.cmake.in"
"${CPM_TARGET_CMAKE_FILE}/CMakeLists.txt"
@ONLY
)
endif()

if (NOT TARGET ${CPM_ARGS_NAME})
add_subdirectory(${CPM_TARGET_CMAKE_FILE} ${CPM_ARGS_BINARY_DIR})
endif()

endfunction()
27 changes: 27 additions & 0 deletions cmake/CPMProject.CMakeLists.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)

if(TARGET @CPM_ARGS_NAME@)
return()
endif()

find_package(@CPM_ARGS_NAME@ @CPM_ARGS_VERSION@ QUIET)

if(${PACKAGE_FOUND})
set_target_properties(@CPM_ARGS_NAME@
PROPERTIES
IMPORTED_GLOBAL True
)
else()

download_project(
PROJ @CPM_ARGS_NAME@
GIT_REPOSITORY @CPM_ARGS_GIT_REPOSITORY@
GIT_TAG @CPM_ARGS_GIT_TAG@
UPDATE_DISCONNECTED 1
GIT_SHALLOW 1
PREFIX @CPM_ARGS_BINARY_DIR@/dl
QUIET
)

add_subdirectory(${@CPM_ARGS_NAME@_SOURCE_DIR} ${@CPM_ARGS_NAME@_BINARY_DIR})
endif()
30 changes: 0 additions & 30 deletions dependencies/LHC/CMakeLists.txt

This file was deleted.

2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
find_package(LarsVisitor REQUIRED)
endif()

add_subdirectory(../dependencies/catch2 ${PROJECT_BINARY_DIR}/catch2)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/catch2 ${PROJECT_BINARY_DIR}/catch2)

# ---- Create binary ----

Expand Down
File renamed without changes.

0 comments on commit fa1d510

Please sign in to comment.