Closed robertodr closed 4 years ago
Pending #59, this will be done like this:
cmake -H. -Bbuild -DXCFun_DIR=<install_prefix>/share/cmake/XCFun
and CMake will find XCFun on the system.
cmake_minimum_required(VERSION 3.6 FATAL_ERROR) project(UseXCFun LANGUAGES CXX) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_STANDARD_REQUIRED ON) include(GNUInstallDirs) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}) find_package(XCFun CONFIG REQUIRED) get_property(_loc TARGET XCFun::xcfun PROPERTY LOCATION) message(STATUS "Found XCFun: ${_loc} (found version ${XCFun_VERSION})") add_executable(use_xcfun use_xcfun.cpp) target_link_libraries(use_xcfun PUBLIC XCFun::xcfun ) set_target_properties(use_xcfun PROPERTIES MACOSX_RPATH ON SKIP_BUILD_RPATH OFF BUILD_WITH_INSTALL_RPATH OFF INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}" INSTALL_RPATH_USE_LINK_PATH ON )
with the source file use_xcfun.cpp:
use_xcfun.cpp
#include <cstdlib> #include <iostream> #ifdef USING_XCFun #include "XCFun/xcfun.h" #endif int main() { #ifdef USING_XCFun std::cout << "We have XCFun" << std::endl; std::cout << xcfun_splash() << std::endl; #endif return EXIT_SUCCESS; }
I assume the same works for Fortran, but I haven't tried.
Done with #98 Will continue in #106
Pending #59, this will be done like this:
and CMake will find XCFun on the system.
with the source file
use_xcfun.cpp
:I assume the same works for Fortran, but I haven't tried.