Skip to content

Commit

Permalink
add dummy project CMakeInSubdir
Browse files Browse the repository at this point in the history
  • Loading branch information
NeroBurner committed Dec 9, 2019
1 parent 39cad40 commit 45c9faa
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmake/configs/default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ hunter_default_version(BoringSSL VERSION 0.0.0-0f5ecd3a8-p0)
hunter_default_version(Box2D VERSION 2.3.1-p0)
hunter_default_version(CLAPACK VERSION 3.2.1)
hunter_default_version(CLI11 VERSION 1.8.0)
hunter_default_version(CMakeInSubdir VERSION 0.0.1)
hunter_default_version(CURL VERSION 7.60.0-p2)
hunter_default_version(CapnProto VERSION 0.7.0)
hunter_default_version(Catch VERSION 2.11.0)
Expand Down
47 changes: 47 additions & 0 deletions cmake/projects/CMakeInSubdir/hunter.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright (c) 2015, David Hirvonen
# All rights reserved.

# !!! DO NOT PLACE HEADER GUARDS HERE !!!

# Load used modules
include(hunter_add_version)
include(hunter_cmake_args)
include(hunter_download)
include(hunter_pick_scheme)
include(hunter_cacheable)
include(hunter_source_subdir)

hunter_cacheable(CMakeInSubdir)

# List of versions here...
hunter_add_version(
PACKAGE_NAME
CMakeInSubdir
VERSION
"0.0.1"
URL
"https://github.com/NeroBurner/cmake_in_subdir/archive/v0.0.1.tar.gz"
SHA1
5791cd5e7e12c30ba1507f1ff29688aa1b9333f5
)

# set the sub-directory the projects CMakeLists.txt is in
hunter_source_subdir(
CMakeInSubdir
SOURCE_SUBDIR "cpp")

# disable Eigen tests. Testcreation tries to find package 'Boost'
hunter_cmake_args(
CMakeInSubdir
CMAKE_ARGS
HUNTER_INSTALL_LICENSE_FILES=LICENSE
)

# Pick a download scheme
hunter_pick_scheme(DEFAULT url_sha1_cmake)

# Download package.
# Two versions of library will be build:
# * libexample_A.a
# * libexample_Ad.a
hunter_download(PACKAGE_NAME CMakeInSubdir)
34 changes: 34 additions & 0 deletions examples/CMakeInSubdir/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright (c) 2015, Ruslan Baratov
# All rights reserved.

cmake_minimum_required(VERSION 3.0)

# Emulate HunterGate:
# * https://github.com/hunter-packages/gate
include("../common.cmake")

project(download-CMakeInSubdir)

# DOCUMENTATION_START {
hunter_add_package(CMakeInSubdir)
find_package(CIS CONFIG REQUIRED)

add_executable(foo foo.cpp)
target_link_libraries(foo CIS::CMakeInSubdir)
# DOCUMENTATION_END }

# Test double library creation
find_package(CIS CONFIG REQUIRED)

string(COMPARE EQUAL "${CMakeInSubdir_LICENSES}" "" is_empty)
if(is_empty)
message(FATAL_ERROR "Licenses not found")
endif()

message("CMakeInS licenses:")
foreach(x ${Eigen_LICENSES})
message("* ${x}")
if(NOT EXISTS "${Eigen_LICENSES}")
message(FATAL_ERROR "File not found")
endif()
endforeach()
7 changes: 7 additions & 0 deletions examples/CMakeInSubdir/foo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <cis.hpp>

#include <iostream>
int main()
{
std::cout << "CMakeInSubdir version: " << cmake_in_subdir::CIS_VERSION << std::endl;
}

0 comments on commit 45c9faa

Please sign in to comment.