Merge remote-tracking branch 'origin/develop' into issue-38
This commit is contained in:
44
tests/add_subdirectory_tests/CMakeLists.txt
Normal file
44
tests/add_subdirectory_tests/CMakeLists.txt
Normal file
@@ -0,0 +1,44 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
|
||||
project(foo)
|
||||
|
||||
set(FORT_ENABLE_TESTING OFF CACHE INTERNAL "")
|
||||
add_subdirectory(libfort)
|
||||
|
||||
# Create target that depend on libfort and check they'll compile ok
|
||||
add_executable(foo-app
|
||||
foo-app.cpp)
|
||||
target_link_libraries(foo-app
|
||||
PRIVATE fort
|
||||
)
|
||||
|
||||
add_library(foo-lib
|
||||
foo-lib.cpp)
|
||||
target_link_libraries(foo-lib
|
||||
PRIVATE fort)
|
||||
|
||||
add_library(foo-lib-shared SHARED
|
||||
foo-lib.cpp)
|
||||
target_link_libraries(foo-lib-shared
|
||||
PRIVATE fort)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
install(
|
||||
TARGETS foo-lib foo-lib-shared
|
||||
EXPORT ${PROJECT_NAME}-targets
|
||||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
install(
|
||||
EXPORT ${PROJECT_NAME}-targets
|
||||
FILE ${PROJECT_NAME}-targets.cmake
|
||||
NAMESPACE ${PROJECT_NAME}::
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
|
||||
)
|
||||
|
16
tests/add_subdirectory_tests/foo-app.cpp
Normal file
16
tests/add_subdirectory_tests/foo-app.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "fort.hpp"
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
fort::char_table table;
|
||||
table << fort::header
|
||||
<< "N" << "Driver" << "Time" << "Avg Speed" << fort::endr
|
||||
<< "1" << "Ricciardo" << "1:25.945" << "47.362" << fort::endr
|
||||
<< "2" << "Hamilton" << "1:26.373" << "35.02" << fort::endr
|
||||
<< "3" << "Verstappen" << "1:26.469" << "29.78" << fort::endr;
|
||||
|
||||
std::cout << table.to_string() << std::endl;
|
||||
}
|
13
tests/add_subdirectory_tests/foo-lib.cpp
Normal file
13
tests/add_subdirectory_tests/foo-lib.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include "fort.hpp"
|
||||
|
||||
std::string print_string()
|
||||
{
|
||||
fort::char_table table;
|
||||
table << fort::header
|
||||
<< "N" << "Driver" << "Time" << "Avg Speed" << fort::endr
|
||||
<< "1" << "Ricciardo" << "1:25.945" << "47.362" << fort::endr
|
||||
<< "2" << "Hamilton" << "1:26.373" << "35.02" << fort::endr
|
||||
<< "3" << "Verstappen" << "1:26.469" << "29.78" << fort::endr;
|
||||
|
||||
return table.to_string();
|
||||
}
|
57
tests/package_tests/CMakeLists.txt
Normal file
57
tests/package_tests/CMakeLists.txt
Normal file
@@ -0,0 +1,57 @@
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
|
||||
project(foo)
|
||||
|
||||
find_package(libfort)
|
||||
|
||||
# Assert exports of libfort
|
||||
if (NOT libfort_FOUND)
|
||||
message(FATAL_ERROR "libfort was not found")
|
||||
endif()
|
||||
if (NOT TARGET libfort::fort)
|
||||
message(FATAL_ERROR "TARGET libfort::fort not found")
|
||||
endif()
|
||||
if (NOT DEFINED libfort_LIBRARIES)
|
||||
message(FATAL_ERROR "libfort_LIBRARIES are not defined")
|
||||
endif()
|
||||
if (NOT ${libfort_VERSION} EQUAL "0.4.0")
|
||||
message(FATAL_ERROR "libfort_VERSION is incorrect")
|
||||
endif()
|
||||
|
||||
# Create target that depend on libfort and check they'll compile ok
|
||||
add_executable(foo-app
|
||||
foo-app.cpp)
|
||||
target_link_libraries(foo-app
|
||||
PRIVATE libfort::fort
|
||||
)
|
||||
|
||||
add_library(foo-lib
|
||||
foo-lib.cpp)
|
||||
target_link_libraries(foo-lib
|
||||
PRIVATE libfort::fort)
|
||||
|
||||
add_library(foo-lib-shared SHARED
|
||||
foo-lib.cpp)
|
||||
target_link_libraries(foo-lib-shared
|
||||
PRIVATE libfort::fort)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
install(
|
||||
TARGETS foo-lib foo-lib-shared
|
||||
EXPORT ${PROJECT_NAME}-targets
|
||||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
install(
|
||||
EXPORT ${PROJECT_NAME}-targets
|
||||
FILE ${PROJECT_NAME}-targets.cmake
|
||||
NAMESPACE ${PROJECT_NAME}::
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
|
||||
)
|
||||
|
16
tests/package_tests/foo-app.cpp
Normal file
16
tests/package_tests/foo-app.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "fort.hpp"
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
fort::char_table table;
|
||||
table << fort::header
|
||||
<< "N" << "Driver" << "Time" << "Avg Speed" << fort::endr
|
||||
<< "1" << "Ricciardo" << "1:25.945" << "47.362" << fort::endr
|
||||
<< "2" << "Hamilton" << "1:26.373" << "35.02" << fort::endr
|
||||
<< "3" << "Verstappen" << "1:26.469" << "29.78" << fort::endr;
|
||||
|
||||
std::cout << table.to_string() << std::endl;
|
||||
}
|
13
tests/package_tests/foo-lib.cpp
Normal file
13
tests/package_tests/foo-lib.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include "fort.hpp"
|
||||
|
||||
std::string print_string()
|
||||
{
|
||||
fort::char_table table;
|
||||
table << fort::header
|
||||
<< "N" << "Driver" << "Time" << "Avg Speed" << fort::endr
|
||||
<< "1" << "Ricciardo" << "1:25.945" << "47.362" << fort::endr
|
||||
<< "2" << "Hamilton" << "1:26.373" << "35.02" << fort::endr
|
||||
<< "3" << "Verstappen" << "1:26.469" << "29.78" << fort::endr;
|
||||
|
||||
return table.to_string();
|
||||
}
|
Reference in New Issue
Block a user