Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenFAST dev not providing linking/include directory in cmake #2435

Closed
ndevelder opened this issue Sep 25, 2024 · 5 comments · Fixed by #2442
Closed

OpenFAST dev not providing linking/include directory in cmake #2435

ndevelder opened this issue Sep 25, 2024 · 5 comments · Fixed by #2442
Assignees
Milestone

Comments

@ndevelder
Copy link
Contributor

I'm getting this when I build with Nalu-Wind +fsi using openfast dev

33 CMake Error at CMakeLists.txt:276 (target_link_libraries):
34 Cannot find source file:
35
36 /projects/wind/hpc/wind/ndeveld/em-exawind-flight/spack/opt/spack/linux-rhel8-sapphirerapids/intel-2023.2.0/openfast-develop-pgz3za5fkapqx45y4dekq6agvkr2oejj/MAP_Types.h

And I'm pretty sure this is because MAP_Types.h got moved to the subdirectory "mappp"? Is there a way for openfast to provide this directory such that find_package picks it up? Or maybe there's a different solution that makes more sense?

@andrew-platt
Copy link
Collaborator

In PR #2392, @sanguinariojoe moved the MAP_Types.h specifically for when MAP is used by a 3rd party. Perhaps he can give us a pointer on how to make sure this is still findable for your use case.

@sanguinariojoe
Copy link
Contributor

In PR #2392, @sanguinariojoe moved the MAP_Types.h specifically for when MAP is used by a 3rd party. Perhaps he can give us a pointer on how to make sure this is still findable for your use case.

I created the following FindMapPP.cmake:

# - Try to find Map++
# Once done this will define
#  MapPP_FOUND - System has Map++
#  MapPP_INCLUDE_DIRS - The Map++ include directories
#  MapPP_LIBRARIES - The library to link Map++

include(FindPackageHandleStandardArgs)

find_path(MapPP_INCLUDE_DIRS_EXT mappp/mapapi.h
          HINTS ${MapPP_ROOT}
          NO_CACHE)

find_library(MapPP_LIBRARIES_EXT NAMES mappp
                                       mappplib
                                       maplib
             HINTS ${MapPP_ROOT}
             NO_CACHE)

if(MapPP_INCLUDE_DIRS_EXT AND MapPP_LIBRARIES_EXT)
    set(MapPP_INCLUDE_DIRS "${MapPP_INCLUDE_DIRS_EXT}" CACHE PATH
        "The Map++ headers directory path")
    set(MapPP_LIBRARIES "${MapPP_LIBRARIES_EXT}" CACHE PATH
        "The Map++ libraries")
    find_package_handle_standard_args(MapPP DEFAULT_MSG
        MapPP_LIBRARIES MapPP_INCLUDE_DIRS)
    return()
endif()

message(STATUS "Map++ not found, trying to download and install it")

find_package(Git)
if(NOT Git_FOUND)
    set(MapPP_INCLUDE_DIRS "${MapPP_INCLUDE_DIRS_EXT}" CACHE PATH
        "The Map++ headers directory path")
    set(MapPP_LIBRARIES "${MapPP_LIBRARIES_EXT}" CACHE PATH
        "The Map++ libraries")
    mark_as_advanced(MapPP_INCLUDE_DIRS MapPP_LIBRARIES)
    find_package_handle_standard_args(MapPP DEFAULT_MSG
        MapPP_LIBRARIES MapPP_INCLUDE_DIRS)
    return()
endif()

file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/extern)
# TODO: Change the URI to https://github.com/OpenFAST/openfast.git when
# https://github.com/OpenFAST/openfast/pull/2394 is merged (or some
# other solution is applied)
if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/extern/openfast)
    execute_process(COMMAND ${GIT_EXECUTABLE} clone https://github.com/core-marine-dev/openfast.git -b dev
                    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/extern
                    RESULT_VARIABLE STATUS)
    if(STATUS AND NOT STATUS EQUAL 0)
        set(MapPP_INCLUDE_DIRS "${MapPP_INCLUDE_DIRS_EXT}" CACHE PATH
            "The Map++ headers directory path")
        set(MapPP_LIBRARIES "${MapPP_LIBRARIES_EXT}" CACHE PATH
            "The Map++ libraries")
        find_package_handle_standard_args(MapPP DEFAULT_MSG
            MapPP_LIBRARIES MapPP_INCLUDE_DIRS)
        return()
    endif()
else()
    execute_process(COMMAND ${GIT_EXECUTABLE} pull origin dev
                    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/extern/openfast)
endif()
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/extern/openfast.build)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/extern/openfast.install)
execute_process(COMMAND ${CMAKE_COMMAND} -B ${CMAKE_CURRENT_BINARY_DIR}/extern/openfast.build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/extern/openfast.install -DBUILD_SHARED_LIBS=ON openfast/
                WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/extern
                RESULT_VARIABLE STATUS)
if(STATUS AND NOT STATUS EQUAL 0)
    set(MapPP_INCLUDE_DIRS "${MapPP_INCLUDE_DIRS_EXT}" CACHE PATH
        "The Map++ headers directory path")
    set(MapPP_LIBRARIES "${MapPP_LIBRARIES_EXT}" CACHE PATH
        "The Map++ libraries")
    find_package_handle_standard_args(MapPP DEFAULT_MSG
        MapPP_LIBRARIES MapPP_INCLUDE_DIRS)
    return()
endif()    
execute_process(COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/extern/openfast.build --config Release --target mappplib
                WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/extern
                RESULT_VARIABLE STATUS)
if(STATUS AND NOT STATUS EQUAL 0)
    set(MapPP_INCLUDE_DIRS "${MapPP_INCLUDE_DIRS_EXT}" CACHE PATH
        "The Map++ headers directory path")
    set(MapPP_LIBRARIES "${MapPP_LIBRARIES_EXT}" CACHE PATH
        "The Map++ libraries")
    find_package_handle_standard_args(MapPP DEFAULT_MSG
        MapPP_LIBRARIES MapPP_INCLUDE_DIRS)
    return()
endif()    
execute_process(COMMAND ${CMAKE_COMMAND} --install ${CMAKE_CURRENT_BINARY_DIR}/extern/openfast.build/modules/map --config Release
                WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/extern
                RESULT_VARIABLE STATUS)
if(STATUS AND NOT STATUS EQUAL 0)
    set(MapPP_INCLUDE_DIRS "${MapPP_INCLUDE_DIRS_EXT}" CACHE PATH
        "The Map++ headers directory path")
    set(MapPP_LIBRARIES "${MapPP_LIBRARIES_EXT}" CACHE PATH
        "The Map++ libraries")
    find_package_handle_standard_args(MapPP DEFAULT_MSG
        MapPP_LIBRARIES MapPP_INCLUDE_DIRS)
    return()
endif()

find_path(MapPP_INCLUDE_DIRS_INT mappp/mapapi.h
          HINTS ${CMAKE_CURRENT_BINARY_DIR}/extern/openfast.install/
          PATH_SUFFIXES include
          NO_CACHE)

find_library(MapPP_LIBRARIES_INT NAMES mappplib
             HINTS ${CMAKE_CURRENT_BINARY_DIR}/extern/openfast.install/
             PATH_SUFFIXES lib lib64
             NO_CACHE)

set(MapPP_INCLUDE_DIRS "${MapPP_INCLUDE_DIRS_INT}" CACHE PATH
    "The Map++ headers directory path")
set(MapPP_LIBRARIES "${MapPP_LIBRARIES_INT}" CACHE PATH
    "The Map++ static library")
if(MapPP_INCLUDE_DIRS_INT AND MapPP_LIBRARIES_INT)
    mark_as_advanced(MapPP_INCLUDE_DIRS MapPP_LIBRARIES)
endif()

find_package_handle_standard_args(MapPP DEFAULT_MSG
    MapPP_LIBRARIES MapPP_INCLUDE_DIRS)

@sanguinariojoe
Copy link
Contributor

P.S. You will need to add the mappp/ prefix to your Map++ includes

@deslaughter deslaughter self-assigned this Sep 27, 2024
@deslaughter deslaughter added this to the v4.0.0 milestone Sep 27, 2024
@deslaughter deslaughter linked a pull request Sep 27, 2024 that will close this issue
@deslaughter
Copy link
Collaborator

@sanguinariojoe Can you take a look at #2442 and let me know if it will affect your usage of the library? This issue is caused by install/lib/cmake/OpenFASTLibraries.cmake not having the correct path to those headers.

@sanguinariojoe
Copy link
Contributor

sanguinariojoe commented Sep 27, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants