From fb521626bec2e7f56c76746c67a62c3968759957 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20Have=CC=81?= Date: Sun, 12 Nov 2023 18:23:04 +0100 Subject: [PATCH] Update CMakeLists to support converted project to C --- CMakeLists.txt | 65 +++++++---------------------------------- examples/CMakeLists.txt | 1 - 2 files changed, 11 insertions(+), 55 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ab6edf..1494ee4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,17 +1,20 @@ cmake_minimum_required(VERSION 3.10) -project(lbfgsb_cpp CXX) +project(lbfgsb_cpp) + +enable_language(C CXX) set(CMAKE_CXX_STANDARD 17) option(BUILD_EXAMPLE "Build example" OFF) -if (CMAKE_GENERATOR MATCHES "Visual Studio") - set(LBFGSB_CMAKE_GENERATOR "Unix Makefiles") -else () - set(LBFGSB_CMAKE_GENERATOR "${CMAKE_GENERATOR}") -endif () - set(HEADERS "include/${PROJECT_NAME}/lbfgsb.hpp") -add_library(${PROJECT_NAME} INTERFACE) +add_library(${PROJECT_NAME} Lbfgsb.3.0/include/lbfgsb/lbfgsb.h + Lbfgsb.3.0/blas.c + Lbfgsb.3.0/lbfgsb.c + Lbfgsb.3.0/linpack.c + Lbfgsb.3.0/s_cmp.c + Lbfgsb.3.0/s_copy.c + Lbfgsb.3.0/timer.c +) add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) set(EMBED_CUSTOM_BLAS ON) @@ -24,53 +27,7 @@ set(EMBED_CUSTOM_BLAS ON) set(lbfgsb_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Lbfgsb.3.0") set(lbfgsb_BINARY_DIR "${CMAKE_BINARY_DIR}/lbfgsb-build") set(lbfgsb_INSTALL_DIR "${CMAKE_BINARY_DIR}/lbfgsb-installed") - -# subbuild for lbfgsb -set(lbfgsb_VIRTUAL_PROJECT "${CMAKE_CURRENT_BINARY_DIR}/lbfgsb-virtual-project") -configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/ExternalFortranProject.cmake.in" - "${lbfgsb_VIRTUAL_PROJECT}/CMakeLists.txt" @ONLY) - - -execute_process( - COMMAND ${CMAKE_COMMAND} - -DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER} - -DFortran_LINK_FLAGS="${Fortran_LINK_FLAGS}" - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_INSTALL_PREFIX=${lbfgsb_INSTALL_DIR} - -DEMBED_CUSTOM_BLAS=${EMBED_CUSTOM_BLAS} - . - RESULT_VARIABLE result - OUTPUT_VARIABLE capturedOutput - ERROR_VARIABLE capturedOutput - WORKING_DIRECTORY "${lbfgsb_VIRTUAL_PROJECT}" -) -STRING(REPLACE "\n" "\n-- " capturedOutput ${capturedOutput}) # show sub cmake with additional -- markers -if (result) - message("${capturedOutput}") - message(FATAL_ERROR "CMake step for lbfgsb-build failed: ${result}") -elseif (LBFGSB_SHOW_BUILD) - message(STATUS "${capturedOutput}") -endif () -execute_process( - COMMAND ${CMAKE_COMMAND} --build . - RESULT_VARIABLE result - OUTPUT_VARIABLE capturedOutput - ERROR_VARIABLE capturedOutput - WORKING_DIRECTORY "${lbfgsb_VIRTUAL_PROJECT}" -) -STRING(REPLACE "\n" "\n-- " capturedOutput ${capturedOutput}) # show sub cmake with additional -- markers -if (result) - message("${capturedOutput}") - message(FATAL_ERROR "Build step for lbfgsb-build failed: ${result}") -elseif (LBFGSB_SHOW_BUILD) - message(STATUS "${capturedOutput}") -endif () -# End of subbuild for lbfgsb - set(lbfgsb_DIR "${lbfgsb_INSTALL_DIR}/lib/cmake/lbfgsb") -find_package(lbfgsb CONFIG REQUIRED) - -target_link_libraries(${PROJECT_NAME} INTERFACE lbfgsb::lbfgsb) target_include_directories( ${PROJECT_NAME} INTERFACE diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index b10bc07..92e0e8d 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,6 +1,5 @@ add_executable(example example.cpp strncmp_debug.cpp) target_link_libraries(example PRIVATE ${PROJECT_NAME}) -target_link_libraries(example PUBLIC lbfgsb::lbfgsb) #target_compile_options( # example PRIVATE # -Wall