Skip to content

Commit

Permalink
Improve gotcha download/install process
Browse files Browse the repository at this point in the history
  • Loading branch information
daboehme committed Jun 6, 2017
1 parent 8bd37b5 commit daab0d6
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 9 deletions.
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,8 @@ endif()

if (WITH_GOTCHA)
set(CALIPER_HAVE_GOTCHA TRUE)
set(GOTCHA_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/ext/gotcha/gotcha-build/include)
set(GOTCHA_LIBRARY ${CMAKE_CURRENT_BINARY_DIR}/ext/gotcha/gotcha-build/lib/libgotcha.so)
list(APPEND CALIPER_EXTERNAL_LIBS ${GOTCHA_LIBRARY})
set(GOTCHA_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/ext/gotcha/gotcha-download/gotcha-src/include)
list(APPEND CALIPER_EXTERNAL_LIBS gotcha)
endif()

find_package(Threads)
Expand Down
30 changes: 24 additions & 6 deletions ext/gotcha/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
include(ExternalProject)
#
# --- gotcha: download gotcha at configure time
#

configure_file(gotcha-download_CMakeLists.txt.in gotcha-download/CMakeLists.txt)

ExternalProject_Add(gotcha
GIT_REPOSITORY "https://www.github.com/LLNL/gotcha"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/gotcha-build -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DGOTCHA_ENABLE_TESTS=Off
BUILD_COMMAND "make"
)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/gotcha-download)

if (result)
message(FATAL_ERROR "CMake step for gotcha failed: ${result}")
endif()

execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/gotcha-download)

if (result)
message(FATAL_ERROR "Build step for gotcha failed: ${result}")
endif()

# Add gotcha directories. Defines gtest and gtest-main targets.
add_subdirectory(
${CMAKE_CURRENT_BINARY_DIR}/gotcha-download/gotcha-src
${CMAKE_CURRENT_BINARY_DIR}/gotcha-download/gotcha-build)
15 changes: 15 additions & 0 deletions ext/gotcha/gotcha-download_CMakeLists.txt.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.0)

project(libgotcha NONE)

include(ExternalProject)
ExternalProject_Add(libgotcha
GIT_REPOSITORY "https://github.com/LLNL/gotcha.git"
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/gotcha-download/gotcha-src"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/gotcha-download/gotcha-build"
CMAKE_ARGS ""
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)

0 comments on commit daab0d6

Please sign in to comment.