feat: working rpm and targz packages with opDefs library
This commit is contained in:
@@ -12,6 +12,8 @@ set(CMAKE_AUTORCC ON)
|
||||
# setup project
|
||||
project(enzo)
|
||||
|
||||
set(ENZO_DEV_LIB_DIR "${CMAKE_SOURCE_DIR}/build/src/OpDefs/")
|
||||
|
||||
set(ENGINE_SOURCES
|
||||
src/Engine/Operator/Attribute.cpp
|
||||
src/Engine/Operator/Geometry.cpp
|
||||
@@ -91,16 +93,28 @@ qt_add_executable(${AppExec}
|
||||
${ENGINE_SOURCES}
|
||||
)
|
||||
|
||||
target_compile_definitions(${AppExec} PRIVATE ENZO_DEV_LIB_DIR="${ENZO_DEV_LIB_DIR}")
|
||||
|
||||
|
||||
# --- packaging ---
|
||||
if(UNIX)
|
||||
set(CPACK_PACKAGING_INSTALL_PREFIX "/opt")
|
||||
endif(UNIX)
|
||||
set(CPACK_PROJECT_CONFIG_FILE ${CMAKE_SOURCE_DIR}/cmake/CPackProjectConfig.cmake)
|
||||
|
||||
set(ENZO_BIN_DIR ${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_PROJECT_NAME}/bin)
|
||||
set(CPACK_GENERATOR "RPM;TGZ")
|
||||
|
||||
set(ENZO_BIN_DIR ${CMAKE_PROJECT_NAME}/bin)
|
||||
set(ENZO_LIB_DIR ${CMAKE_PROJECT_NAME}/lib)
|
||||
|
||||
install(
|
||||
TARGETS ${AppExec}
|
||||
RUNTIME DESTINATION ${ENZO_BIN_DIR}
|
||||
LIBRARY DESTINATION ${ENZO_LIB_DIR}
|
||||
ARCHIVE DESTINATION ${ENZO_LIB_DIR}
|
||||
)
|
||||
|
||||
install(TARGETS ${AppExec} RUNTIME DESTINATION ${ENZO_BIN_DIR})
|
||||
include(CPack)
|
||||
|
||||
# set(CPACK_RPM_PACKAGE_REQUIRES "openssl >= 1.1.1, zlib >= 1.2.11")
|
||||
|
||||
# --- end packaging
|
||||
|
||||
|
||||
|
||||
12
cmake/CPackProjectConfig.cmake
Normal file
12
cmake/CPackProjectConfig.cmake
Normal file
@@ -0,0 +1,12 @@
|
||||
if (CPACK_GENERATOR MATCHES "RPM")
|
||||
# rpm specific config
|
||||
|
||||
if(UNIX)
|
||||
set(CPACK_PACKAGING_INSTALL_PREFIX "/opt")
|
||||
endif(UNIX)
|
||||
|
||||
elseif(CPACK_GENERATOR MATCHES "TGZ")
|
||||
# tgz specific config
|
||||
|
||||
endif()
|
||||
|
||||
@@ -2,8 +2,13 @@
|
||||
#include "Engine/Operator/OpInfo.h"
|
||||
#include "Engine/Types.h"
|
||||
#include <boost/dll/import.hpp>
|
||||
#include <boost/dll/runtime_symbol_info.hpp>
|
||||
#include <boost/filesystem/file_status.hpp>
|
||||
#include <icecream.hpp>
|
||||
|
||||
#include <boost/dll/shared_library.hpp>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
void enzo::op::OperatorTable::addOperator(enzo::op::OpInfo info)
|
||||
{
|
||||
@@ -48,13 +53,59 @@ std::vector<enzo::op::OpInfo> enzo::op::OperatorTable::getData()
|
||||
return opInfoStore_;
|
||||
}
|
||||
|
||||
boost::filesystem::path enzo::op::OperatorTable::findPlugin(const std::string& undecoratedLibName)
|
||||
{
|
||||
|
||||
const auto libName = boost::dll::shared_library::decorate(undecoratedLibName);
|
||||
|
||||
// check for lib dir
|
||||
{
|
||||
const boost::filesystem::path executable = boost::dll::program_location();
|
||||
const boost::filesystem::path enzoRoot = executable.parent_path().parent_path();
|
||||
const boost::filesystem::path enzoLib = enzoRoot / "lib";
|
||||
const boost::filesystem::path candidate = enzoLib / libName;
|
||||
|
||||
if(boost::filesystem::exists(candidate))
|
||||
{
|
||||
IC(candidate);
|
||||
return candidate;
|
||||
}
|
||||
else std::cout << "Couldn't find lib at: " << candidate.string() << "\n";
|
||||
}
|
||||
|
||||
// check for dev macro
|
||||
#ifndef ENZO_DEV_LIB_DIR
|
||||
#define ENZO_DEV_LIB_DIR ""
|
||||
#endif
|
||||
if(std::string(ENZO_DEV_LIB_DIR).size())
|
||||
{
|
||||
const auto candidate = boost::filesystem::path(ENZO_DEV_LIB_DIR) / libName;
|
||||
if(boost::filesystem::exists(candidate))
|
||||
{
|
||||
IC(candidate);
|
||||
return candidate;
|
||||
}
|
||||
else std::cout << "Couldn't find lib at: " << candidate.string() << "\n";
|
||||
}
|
||||
|
||||
|
||||
// TODO: add env var finder
|
||||
// TODO: add same dirfinder
|
||||
|
||||
throw std::runtime_error("Couldn't find plugin: " + libName.string());
|
||||
}
|
||||
|
||||
|
||||
void enzo::op::OperatorTable::initPlugins()
|
||||
{
|
||||
static bool pluginsLoaded=false;
|
||||
if(pluginsLoaded) return;
|
||||
|
||||
// auto initPlugin = boost::dll::import_symbol<void(enzo::op::addOperatorPtr)>(
|
||||
// "build/src/OpDefs/libenzoOps1.so", "newSopOperator"
|
||||
// );
|
||||
auto initPlugin = boost::dll::import_symbol<void(enzo::op::addOperatorPtr)>(
|
||||
"build/src/OpDefs/libenzoOps1.so", "newSopOperator"
|
||||
findPlugin("enzoOps1"), "newSopOperator"
|
||||
);
|
||||
|
||||
initPlugin(enzo::op::OperatorTable::addOperator);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "Engine/Operator/GeometryOpDef.h"
|
||||
#include "Engine/Operator/OpInfo.h"
|
||||
#include "Engine/Parameter/Template.h"
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
|
||||
namespace enzo::op
|
||||
@@ -17,6 +18,7 @@ public:
|
||||
static nt::opConstructor getOpConstructor(std::string name);
|
||||
static const std::optional<op::OpInfo> getOpInfo(std::string name);
|
||||
static std::vector<OpInfo> getData();
|
||||
static boost::filesystem::path findPlugin(const std::string& undecoratedLibName);
|
||||
// TODO: move to better spot (maybe engine class)
|
||||
static void initPlugins();
|
||||
private:
|
||||
|
||||
@@ -32,6 +32,12 @@ add_library(${libName} SHARED
|
||||
)
|
||||
target_link_libraries(${libName} PRIVATE Qt6::Core Qt6::Widgets Qt6::SvgWidgets Qt6::OpenGLWidgets glm::glm Eigen3::Eigen TBB::tbb)
|
||||
|
||||
# packaging
|
||||
install(TARGETS ${libName}
|
||||
LIBRARY DESTINATION ${ENZO_LIB_DIR}
|
||||
ARCHIVE DESTINATION ${ENZO_LIB_DIR}
|
||||
)
|
||||
|
||||
|
||||
MESSAGE("CURRENT SOURCE DIR" ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_include_directories(${libName} PUBLIC
|
||||
|
||||
@@ -25,28 +25,28 @@ extern "C"
|
||||
1,
|
||||
}
|
||||
);
|
||||
addOperator(
|
||||
enzo::op::OpInfo {
|
||||
"house",
|
||||
"House",
|
||||
&GOP_house::ctor,
|
||||
GOP_house::parameterList,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
}
|
||||
);
|
||||
addOperator(
|
||||
enzo::op::OpInfo {
|
||||
"testGeoCube",
|
||||
"Test Cube",
|
||||
&GopTestGeoCube::ctor,
|
||||
GopTestGeoCube::parameterList,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
}
|
||||
);
|
||||
// addOperator(
|
||||
// enzo::op::OpInfo {
|
||||
// "house",
|
||||
// "House",
|
||||
// &GOP_house::ctor,
|
||||
// GOP_house::parameterList,
|
||||
// 0,
|
||||
// 0,
|
||||
// 1,
|
||||
// }
|
||||
// );
|
||||
// addOperator(
|
||||
// enzo::op::OpInfo {
|
||||
// "testGeoCube",
|
||||
// "Test Cube",
|
||||
// &GopTestGeoCube::ctor,
|
||||
// GopTestGeoCube::parameterList,
|
||||
// 0,
|
||||
// 0,
|
||||
// 1,
|
||||
// }
|
||||
// );
|
||||
addOperator(
|
||||
enzo::op::OpInfo {
|
||||
"geometryImport",
|
||||
|
||||
Reference in New Issue
Block a user