Skip to content

Commit

Permalink
Support building against external liborigin
Browse files Browse the repository at this point in the history
  • Loading branch information
MehdiChinoune committed Mar 2, 2024
1 parent c76af11 commit 0412511
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/linux-weekly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ jobs:
glu \
gsl \
muparser \
liborigin \
qwt \
gl2ps \
sip \
Expand Down Expand Up @@ -394,6 +395,7 @@ jobs:
ninja \
gsl-devel \
muparser-devel \
liborigin-devel \
qwt6-qt${{ matrix.QT_VER }}-devel \
gl2ps-devel \
zlib-devel \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ jobs:

- name: Install prerequisties
run: |
brew install --display-times muparser gsl gl2ps googletest
brew install --display-times muparser liborigin gsl gl2ps googletest
if [[ "${{ matrix.QT_VER }}" == "5.15" ]]; then
brew install qwt-qt5
fi
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ jobs:

- name: Install prerequisties
run: |
brew install --display-times muparser gsl gl2ps
brew install --display-times muparser liborigin gsl gl2ps
if [[ ${{ matrix.QT_VER }} == 6 ]]; then
brew install qwt
else
Expand Down Expand Up @@ -543,6 +543,7 @@ jobs:
libqt5-linguist-devel \
gsl-devel \
muparser-devel \
liborigin-devel \
qwt6-qt5-devel \
gl2ps-devel \
zlib-devel \
Expand Down
9 changes: 8 additions & 1 deletion 3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,12 @@ add_subdirectory( qwtplot3d )

# liborigin
if( MAKHBER_ORIGIN_IMPORT )
add_subdirectory( liborigin )
if(NOT LIBORIGIN_FOUND)
add_subdirectory( liborigin )
if(BUILD_SHARED_LIBS)
add_library(liborigin::liborigin ALIAS origin_shared)
else()
add_library(liborigin::liborigin ALIAS origin_static)
endif()
endif()
endif()
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ find_package( OpenGL COMPONENTS OpenGL REQUIRED )

find_package( muparser REQUIRED )

find_package(liborigin 3.0)

find_package( Qwt ${MINIMUM_QWT} REQUIRED )
# Qwt<6.2 couldn't be used with c++20
if(Qwt_VERSION VERSION_LESS 6.2)
Expand Down
47 changes: 47 additions & 0 deletions cmake/Findliborigin.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

set(LIBORIGIN_ROOT_DIR "${LIBORIGIN_ROOT_DIR}" CACHE PATH "Directory to search for liborigin" )

find_package(PkgConfig QUIET)
if( PkgConfig_FOUND )
pkg_search_module(PC_LIBORIGIN QUIET liborigin)
if( PC_LIBORIGIN_FOUND )
set( LIBORIGIN_VERSION ${PC_LIBORIGIN_VERSION} )
endif()
endif()

find_path( LIBORIGIN_INCLUDE_DIR
NAMES OriginFile.h
PATHS "${LIBORIGIN_ROOT_DIR}"
HINTS ${PC_LIBORIGIN_INCLUDEDIR} ${PC_LIBORIGIN_INCLUDE_DIRS}
PATH_SUFFIXES liborigin
)
find_library( LIBORIGIN_LIBRARY
NAMES origin
PATHS "${LIBORIGIN_ROOT_DIR}"
HINTS ${PC_LIBORIGIN_LIBDIR} ${PC_LIBORIGIN_LIBRARY_DIRS}
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args( liborigin
FOUND_VAR LIBORIGIN_FOUND
REQUIRED_VARS
LIBORIGIN_LIBRARY
LIBORIGIN_INCLUDE_DIR
VERSION_VAR LIBORIGIN_VERSION
)

if(LIBORIGIN_FOUND)
set(LIBORIGIN_INCLUDE_DIRS ${LIBORIGIN_INCLUDE_DIR})
set(LIBORIGIN_LIBRARIES ${LIBORIGIN_LIBRARY})
if(NOT TARGET liborigin::liborigin)
add_library(liborigin::liborigin UNKNOWN IMPORTED)
set_target_properties( liborigin::liborigin
PROPERTIES
IMPORTED_LOCATION "${LIBORIGIN_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${LIBORIGIN_INCLUDE_DIR}"
)
endif()
mark_as_advanced(LIBORIGIN_ROOT_DIR)
endif()

mark_as_advanced(LIBORIGIN_INCLUDE_DIR LIBORIGIN_LIBRARY)
6 changes: 4 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,10 @@ endif()

if( MAKHBER_ORIGIN_IMPORT )
target_sources( libmakhber PRIVATE "core/importOPJ.h" "core/importOPJ.cpp" )
target_link_libraries( libmakhber $<IF:$<BOOL:${BUILD_SHARED_LIBS}>,origin_shared,origin_static> )
target_include_directories( libmakhber PUBLIC "${CMAKE_SOURCE_DIR}/3rdparty/liborigin" )
target_link_libraries( libmakhber liborigin::liborigin )
if(NOT LIBORIGIN_FOUND)
target_include_directories( libmakhber PUBLIC "${CMAKE_SOURCE_DIR}/3rdparty/liborigin" )
endif()
target_compile_definitions( libmakhber PUBLIC ORIGIN_IMPORT )
endif()

Expand Down

0 comments on commit 0412511

Please sign in to comment.