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

ENH: Import libLBFGS from upstream #5175

Merged
merged 5 commits into from
Jan 26, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
ENH: Integrate libLBFGS into our CMake build system
Fixes: #3135
bradking committed Jan 24, 2025
commit 2f2dcf574f7b58a11d17f0e466834d3179dd998d
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@
#include "ITKOptimizersv4Export.h"
#include <memory>

#include "lbfgs.h"
#include "itk_lbfgs.h"

namespace itk
{
7 changes: 6 additions & 1 deletion Modules/ThirdParty/libLBFGS/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -13,9 +13,14 @@ set(ITKLIBLBFGS_THIRD_PARTY 1)
# set(ITKLIBLBFGS_NO_SRC 1)
#else()

set(ITKLIBLBFGS_INCLUDE_DIRS ${ITKLIBLBFGS_SOURCE_DIR}/include )
set(ITKLIBLBFGS_INCLUDE_DIRS ${ITKLIBLBFGS_SOURCE_DIR}/src)
set(ITKLIBLBFGS_LIBRARIES itklbfgs)

#endif()

itk_module_impl()

install(FILES ${ITKLIBLBFGS_SOURCE_DIR}/src/itk_lbfgs.h
DESTINATION ${ITKLIBLBFGS_INSTALL_INCLUDE_DIR}
COMPONENT Development
)
20 changes: 1 addition & 19 deletions Modules/ThirdParty/libLBFGS/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,7 @@
ADD_LIBRARY( itklbfgs
lbfgs.c
)

IF(ITK_LIBRARY_PROPERTIES)
SET_TARGET_PROPERTIES(itklbfgs PROPERTIES ${ITK_LIBRARY_PROPERTIES})
ENDIF(ITK_LIBRARY_PROPERTIES)

set(ITK3P_INSTALL_EXPORT_NAME "${ITKLIBLBFGS-targets}")
set(ITK3P_INSTALL_INCLUDE_DIR "${ITKLIBLBFGS_INSTALL_INCLUDE_DIR}")
set(ITK3P_INSTALL_RUNTIME_DIR "${ITKLIBLBFGS_INSTALL_RUNTIME_DIR}")
set(ITK3P_INSTALL_LIBRARY_DIR "${ITKLIBLBFGS_INSTALL_LIBRARY_DIR}")
set(ITK3P_INSTALL_ARCHIVE_DIR "${ITKLIBLBFGS_INSTALL_ARCHIVE_DIR}")

IF(UNIX)
TARGET_LINK_LIBRARIES(itklbfgs m)
ENDIF(UNIX)

INSTALL(TARGETS itklbfgs
EXPORT ${ITK3P_INSTALL_EXPORT_NAME}
RUNTIME DESTINATION ${ITK3P_INSTALL_RUNTIME_DIR} COMPONENT RuntimeLibraries
LIBRARY DESTINATION ${ITK3P_INSTALL_LIBRARY_DIR} COMPONENT RuntimeLibraries
ARCHIVE DESTINATION ${ITK3P_INSTALL_ARCHIVE_DIR} COMPONENT Development)

add_subdirectory(itklbfgs)
itk_module_target(itklbfgs NO_INSTALL)
27 changes: 27 additions & 0 deletions Modules/ThirdParty/libLBFGS/src/itk_lbfgs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*=========================================================================
*
* Copyright NumFOCUS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
/*=========================================================================
* Include file to wrap the internal ITK libLBFGS library header
*=========================================================================*/

#ifndef itk_lbfgs_h
#define itk_lbfgs_h

#include <itklbfgs/include/lbfgs.h>

#endif
20 changes: 20 additions & 0 deletions Modules/ThirdParty/libLBFGS/src/itklbfgs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
add_library(itklbfgs lib/lbfgs.c)
target_include_directories(itklbfgs PRIVATE include)

if(ITK_LIBRARY_PROPERTIES)
set_target_properties(itklbfgs PROPERTIES ${ITK_LIBRARY_PROPERTIES})
endif()

if(UNIX)
target_link_libraries(itklbfgs m)
endif()

install(TARGETS itklbfgs
EXPORT ${ITK3P_INSTALL_EXPORT_NAME}
RUNTIME DESTINATION ${ITK3P_INSTALL_RUNTIME_DIR} COMPONENT RuntimeLibraries
LIBRARY DESTINATION ${ITK3P_INSTALL_LIBRARY_DIR} COMPONENT RuntimeLibraries
ARCHIVE DESTINATION ${ITK3P_INSTALL_ARCHIVE_DIR} COMPONENT Development)

install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/include/lbfgs.h
DESTINATION ${ITK3P_INSTALL_INCLUDE_DIR}/itklbfgs/include)