Skip to content

Commit

Permalink
Use find_package for ManiVault (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
alxvth authored Jul 30, 2024
1 parent 42a0d70 commit ee07105
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 51 deletions.
28 changes: 9 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,6 @@ if(MSVC)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
endif(MSVC)

# -----------------------------------------------------------------------------
# Set install directory
# -----------------------------------------------------------------------------
# Check if the directory to the ManiVault installation has been provided
if(NOT DEFINED MV_INSTALL_DIR)
set(MV_INSTALL_DIR "" CACHE PATH "Directory where ManiVault is installed")
message(FATAL_ERROR "Please set MV_INSTALL_DIR to the directory where ManiVault is installed")
endif()
file(TO_CMAKE_PATH ${MV_INSTALL_DIR} MV_INSTALL_DIR)

# Checks whether this is the first CMake run for this project.
# If so, sets the CMake Install Prefix to the ManiVault install directory.
# This if-statement must be placed after the project() command to work.
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${MV_INSTALL_DIR} CACHE PATH "..." FORCE)
endif()

message(STATUS "MV_INSTALL_DIR set to ${MV_INSTALL_DIR}")

# -----------------------------------------------------------------------------
# Install dependency libraries
# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -108,6 +89,8 @@ endif()

find_package(Qt6 6.3.1 COMPONENTS Widgets WebEngineWidgets REQUIRED)

find_package(ManiVault COMPONENTS Core PointData ImageData CONFIG)

find_package(OpenGL REQUIRED)
find_package(OpenMP)

Expand All @@ -124,6 +107,13 @@ set(THIRD_PARTY_JSON
${CMAKE_CURRENT_SOURCE_DIR}/third_party/json/nlohmann/json.hpp
)

# Checks whether this is the first CMake run for this project.
# If so, sets the CMake Install Prefix to the ManiVault install directory.
# This if-statement must be placed after the project() command to work.
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${MV_INSTALL_DIR} CACHE PATH "..." FORCE)
endif()

# -----------------------------------------------------------------------------
# Project targets
# -----------------------------------------------------------------------------
Expand Down
24 changes: 7 additions & 17 deletions cmake/CMakeHsneProject.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ add_library(${HSNE_PLUGIN} SHARED
# -----------------------------------------------------------------------------
# Target include directories
# -----------------------------------------------------------------------------
# Include ManiVault core headers
target_include_directories(${HSNE_PLUGIN} PRIVATE "${MV_INSTALL_DIR}/$<CONFIGURATION>/include/")

target_include_directories(${HSNE_PLUGIN} PRIVATE "${ManiVault_INCLUDE_DIR}")
target_include_directories(${HSNE_PLUGIN} PRIVATE "src/Common")
target_include_directories(${HSNE_PLUGIN} PRIVATE "third_party/json")

Expand All @@ -57,17 +55,9 @@ endif()
target_link_libraries(${HSNE_PLUGIN} PRIVATE Qt6::Widgets)
target_link_libraries(${HSNE_PLUGIN} PRIVATE Qt6::WebEngineWidgets)

set(MV_LINK_PATH "${MV_INSTALL_DIR}/$<CONFIGURATION>/lib")
set(PLUGIN_LINK_PATH "${MV_INSTALL_DIR}/$<CONFIGURATION>/$<IF:$<CXX_COMPILER_ID:MSVC>,lib,Plugins>")
set(MV_LINK_SUFFIX $<IF:$<CXX_COMPILER_ID:MSVC>,${CMAKE_LINK_LIBRARY_SUFFIX},${CMAKE_SHARED_LIBRARY_SUFFIX}>)

set(MV_LINK_LIBRARY "${MV_LINK_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}MV_Public${MV_LINK_SUFFIX}")
set(POINTDATA_LINK_LIBRARY "${PLUGIN_LINK_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}PointData${MV_LINK_SUFFIX}")
set(IMAGEDATA_LINK_LIBRARY "${PLUGIN_LINK_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}ImageData${MV_LINK_SUFFIX}")

target_link_libraries(${HSNE_PLUGIN} PRIVATE "${MV_LINK_LIBRARY}")
target_link_libraries(${HSNE_PLUGIN} PRIVATE "${POINTDATA_LINK_LIBRARY}")
target_link_libraries(${HSNE_PLUGIN} PRIVATE "${IMAGEDATA_LINK_LIBRARY}")
target_link_libraries(${HSNE_PLUGIN} PRIVATE ManiVault::Core)
target_link_libraries(${HSNE_PLUGIN} PRIVATE ManiVault::PointData)
target_link_libraries(${HSNE_PLUGIN} PRIVATE ManiVault::ImageData)

target_link_libraries(${HSNE_PLUGIN} PRIVATE ${OPENGL_LIBRARIES})

Expand Down Expand Up @@ -98,7 +88,7 @@ if (NOT DEFINED ENV{CI})
--install ${PROJECT_BINARY_DIR}
--config $<CONFIGURATION>
--component PLUGIN_HSNE
--prefix ${MV_INSTALL_DIR}/$<CONFIGURATION>
--prefix ${ManiVault_INSTALL_DIR}/$<CONFIGURATION>
--verbose
)
endif()
Expand All @@ -108,6 +98,6 @@ endif()
# -----------------------------------------------------------------------------
# Automatically set the debug environment (command + working directory) for MSVC
if(MSVC)
set_property(TARGET ${HSNE_PLUGIN} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY $<IF:$<CONFIG:DEBUG>,${MV_INSTALL_DIR}/debug,${MV_INSTALL_DIR}/release>)
set_property(TARGET ${HSNE_PLUGIN} PROPERTY VS_DEBUGGER_COMMAND $<IF:$<CONFIG:DEBUG>,"${MV_INSTALL_DIR}/debug/ManiVault Studio.exe","${MV_INSTALL_DIR}/release/ManiVault Studio.exe">)
set_property(TARGET ${HSNE_PLUGIN} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY $<IF:$<CONFIG:DEBUG>,${ManiVault_INSTALL_DIR}/debug,${ManiVault_INSTALL_DIR}/release>)
set_property(TARGET ${HSNE_PLUGIN} PROPERTY VS_DEBUGGER_COMMAND $<IF:$<CONFIG:DEBUG>,"${ManiVault_INSTALL_DIR}/debug/ManiVault Studio.exe","${ManiVault_INSTALL_DIR}/release/ManiVault Studio.exe">)
endif()
21 changes: 6 additions & 15 deletions cmake/CMakeTsneProject.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ add_library(${TSNE_PLUGIN} SHARED
# -----------------------------------------------------------------------------
# Target include directories
# -----------------------------------------------------------------------------
# Include ManiVault core headers
target_include_directories(${TSNE_PLUGIN} PRIVATE "${MV_INSTALL_DIR}/$<CONFIGURATION>/include/")

target_include_directories(${TSNE_PLUGIN} PRIVATE "${ManiVault_INCLUDE_DIR}")
target_include_directories(${TSNE_PLUGIN} PRIVATE "src/Common")

set_HDILib_project_includes(${TSNE_PLUGIN})
Expand All @@ -54,15 +52,8 @@ endif()
target_link_libraries(${TSNE_PLUGIN} PRIVATE Qt6::Widgets)
target_link_libraries(${TSNE_PLUGIN} PRIVATE Qt6::WebEngineWidgets)

set(MV_LINK_PATH "${MV_INSTALL_DIR}/$<CONFIGURATION>/lib")
set(PLUGIN_LINK_PATH "${MV_INSTALL_DIR}/$<CONFIGURATION>/$<IF:$<CXX_COMPILER_ID:MSVC>,lib,Plugins>")
set(MV_LINK_SUFFIX $<IF:$<CXX_COMPILER_ID:MSVC>,${CMAKE_LINK_LIBRARY_SUFFIX},${CMAKE_SHARED_LIBRARY_SUFFIX}>)

set(MV_LINK_LIBRARY "${MV_LINK_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}MV_Public${MV_LINK_SUFFIX}")
set(POINTDATA_LINK_LIBRARY "${PLUGIN_LINK_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}PointData${MV_LINK_SUFFIX}")

target_link_libraries(${TSNE_PLUGIN} PRIVATE "${MV_LINK_LIBRARY}")
target_link_libraries(${TSNE_PLUGIN} PRIVATE "${POINTDATA_LINK_LIBRARY}")
target_link_libraries(${TSNE_PLUGIN} PRIVATE ManiVault::Core)
target_link_libraries(${TSNE_PLUGIN} PRIVATE ManiVault::PointData)

target_link_libraries(${TSNE_PLUGIN} PRIVATE ${OPENGL_LIBRARIES})

Expand Down Expand Up @@ -93,7 +84,7 @@ if (NOT DEFINED ENV{CI})
--install ${PROJECT_BINARY_DIR}
--config $<CONFIGURATION>
--component PLUGIN_TSNE
--prefix ${MV_INSTALL_DIR}/$<CONFIGURATION>
--prefix ${ManiVault_INSTALL_DIR}/$<CONFIGURATION>
--verbose
)
endif()
Expand All @@ -103,6 +94,6 @@ endif()
# -----------------------------------------------------------------------------
# Automatically set the debug environment (command + working directory) for MSVC
if(MSVC)
set_property(TARGET ${TSNE_PLUGIN} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY $<IF:$<CONFIG:DEBUG>,${MV_INSTALL_DIR}/debug,${MV_INSTALL_DIR}/release>)
set_property(TARGET ${TSNE_PLUGIN} PROPERTY VS_DEBUGGER_COMMAND $<IF:$<CONFIG:DEBUG>,"${MV_INSTALL_DIR}/debug/ManiVault Studio.exe","${MV_INSTALL_DIR}/release/ManiVault Studio.exe">)
set_property(TARGET ${TSNE_PLUGIN} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY $<IF:$<CONFIG:DEBUG>,${ManiVault_INSTALL_DIR}/debug,${ManiVault_INSTALL_DIR}/release>)
set_property(TARGET ${TSNE_PLUGIN} PROPERTY VS_DEBUGGER_COMMAND $<IF:$<CONFIG:DEBUG>,"${ManiVault_INSTALL_DIR}/debug/ManiVault Studio.exe","${ManiVault_INSTALL_DIR}/release/ManiVault Studio.exe">)
endif()
4 changes: 4 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ def generate(self):
# Give the installation directory to CMake
tc.variables["MV_INSTALL_DIR"] = self.install_dir

# Find ManiVault with find_package
self.manivault_dir = self.install_dir + '/cmake/mv/'
tc.variables["ManiVault_DIR"] = self.manivault_dir

# Set some build options
tc.variables["MV_UNITY_BUILD"] = "ON"

Expand Down

0 comments on commit ee07105

Please sign in to comment.