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

Always build openfastcpplib as shared. Use BUILD_OPENFAST_CPP_DRIVER to disable openfastcpp executable #2311

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 33 additions & 21 deletions glue-codes/openfast-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ find_package(MPI REQUIRED)
find_package(LibXml2 REQUIRED)
find_package(ZLIB REQUIRED)
find_package(HDF5 REQUIRED COMPONENTS C HL)
find_package(yaml-cpp REQUIRED)

add_library(openfastcpplib src/OpenFAST.cpp src/SC.cpp)
add_library(openfastcpplib SHARED src/OpenFAST.cpp src/SC.cpp)
set_property(TARGET openfastcpplib PROPERTY POSITION_INDEPENDENT_CODE ON)
target_link_libraries(openfastcpplib
openfastlib
Expand All @@ -48,28 +47,41 @@ target_include_directories(openfastcpplib PUBLIC
)
set_target_properties(openfastcpplib PROPERTIES PUBLIC_HEADER "src/OpenFAST.H;src/SC.h")

add_executable(openfastcpp src/FAST_Prog.cpp)
target_link_libraries(openfastcpp
${YAML_CPP_LIBRARIES}
openfastcpplib
)
target_include_directories(openfastcpp PRIVATE ${YAML_CPP_INCLUDE_DIR})
set_target_properties(openfastcpp PROPERTIES LINKER_LANGUAGE CXX)

if(MPI_COMPILE_FLAGS)
set_target_properties(openfastcpp PROPERTIES
COMPILE_FLAGS "${MPI_COMPILE_FLAGS}")
endif(MPI_COMPILE_FLAGS)

if(MPI_LINK_FLAGS)
set_target_properties(openfastcpp PROPERTIES
LINK_FLAGS "${MPI_LINK_FLAGS}")
endif(MPI_LINK_FLAGS)

install(TARGETS openfastcpp openfastcpplib
install(TARGETS openfastcpplib
EXPORT "${CMAKE_PROJECT_NAME}Libraries"
RUNTIME DESTINATION lib
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include
)

# Build driver if requested
if (BUILD_OPENFAST_CPP_DRIVER)

find_package(yaml-cpp REQUIRED)
add_executable(openfastcpp src/FAST_Prog.cpp)
target_link_libraries(openfastcpp
${YAML_CPP_LIBRARIES}
openfastcpplib
)
target_include_directories(openfastcpp PRIVATE ${YAML_CPP_INCLUDE_DIR})
set_target_properties(openfastcpp PROPERTIES LINKER_LANGUAGE CXX)

if(MPI_COMPILE_FLAGS)
set_target_properties(openfastcpp PROPERTIES
COMPILE_FLAGS "${MPI_COMPILE_FLAGS}")
endif(MPI_COMPILE_FLAGS)

if(MPI_LINK_FLAGS)
set_target_properties(openfastcpp PROPERTIES
LINK_FLAGS "${MPI_LINK_FLAGS}")
endif(MPI_LINK_FLAGS)

install(TARGETS openfastcpp
EXPORT "${CMAKE_PROJECT_NAME}Libraries"
RUNTIME DESTINATION lib
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include
)
endif()