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

Fixes to allow building ETISS Plugins out-of tree #150

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ configure_file(
@ONLY
)
install(FILES
"${PROJECT_SOURCE_DIR}/cmake/ETISSPlugin.cmake"
"${PROJECT_BINARY_DIR}/ETISSConfig.cmake"
"${PROJECT_BINARY_DIR}/ETISSConfigVersion.cmake"
DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT dev)
Expand Down
9 changes: 5 additions & 4 deletions ETISSConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ else()
set(ETISS_SHLIB_DLL_PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX})
set(ETISS_SHLIB_DLL_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
endif()
set(ETISS_LIBRARIES "@CMAKE_INSTALL_PREFIX@/lib/${ETISS_SHLIB_DLL_PREFIX}ETISS${ETISS_SHLIB_DLL_SUFFIX}")
set(ETISS_LIB_DIR "@CMAKE_INSTALL_PREFIX@/lib/")
set(ETISS_LIBRARIES "${ETISS_LIB_DIR}/${ETISS_SHLIB_DLL_PREFIX}ETISS${ETISS_SHLIB_DLL_SUFFIX}")

FIND_PACKAGE(Threads REQUIRED)
FIND_PACKAGE(Boost 1.48 COMPONENTS filesystem system program_options REQUIRED)

LINK_DIRECTORIES("${Boost_LIBRARY_DIRS}")
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
LINK_DIRECTORIES("${Boost_LIBRARY_DIRS}" "${ETISS_LIB_DIR}")
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR} "${ETISS_INCLUDE_DIRS}")

SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
if (NOT ETISS_DISABLE_COMPILERFLAGS)
Expand All @@ -56,7 +57,7 @@ if (NOT ETISS_DISABLE_COMPILERFLAGS)
endif()
SET(CMAKE_EXPORT_COMPILE_COMMANDS ON)

file(GLOB_RECURSE SUBPROJECTS_CMAKE "@CMAKE_INSTALL_PREFIX@/cmake/*.cmake")
file(GLOB_RECURSE SUBPROJECTS_CMAKE "@CMAKE_INSTALL_PREFIX@/lib/CMake/ETISS/*.cmake")
string(REGEX REPLACE "[^;]ETISSConfig.cmake;?" "" SUBPROJECTS_CMAKE "${SUBPROJECTS_CMAKE}")
string(REGEX REPLACE "[^;]*ConfigVersion.cmake;?" "" SUBPROJECTS_CMAKE "${SUBPROJECTS_CMAKE}")
foreach(sp ${SUBPROJECTS_CMAKE})
Expand Down
10 changes: 7 additions & 3 deletions cmake/ETISSPlugin.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
MACRO(ETISSPlugin ProjName)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} PUBLIC ETISS)
TARGET_COMPILE_DEFINITIONS(${PROJECT_NAME} PRIVATE ETISS_EXPORTS ETISS_PLUGIN_IMPORTS)
set_target_properties(${ProjName} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${ETISS_BINARY_DIR}/lib/plugins/)
IF(ETISS_BINARY_DIR)
set_target_properties(${ProjName} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${ETISS_BINARY_DIR}/lib/plugins/)
ENDIF()

INSTALL(TARGETS ${ProjName}
RUNTIME DESTINATION lib/plugins
Expand All @@ -16,8 +18,10 @@ MACRO(ETISSPlugin ProjName)
)

# mimicing installation in build tree as well
file(APPEND ${ETISS_BINARY_DIR}/lib/plugins/list.txt
"${ProjName},${ETISS_BINARY_DIR}/lib/plugins,${ProjName}\n")
IF(ETISS_BINARY_DIR)
file(APPEND ${ETISS_BINARY_DIR}/lib/plugins/list.txt
"${ProjName},${ETISS_BINARY_DIR}/lib/plugins,${ProjName}\n")
ENDIF()
ENDMACRO()

MACRO(ETISSPluginArchName ProjName ArchName)
Expand Down
10 changes: 8 additions & 2 deletions src/ETISS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,10 @@ void etiss::Initializer::loadIniPlugins(std::shared_ptr<etiss::CPUCore> cpu)
continue;
}
etiss::log(etiss::INFO, " Adding Plugin " + *pluginName + "\n");
cpu->addPlugin(etiss::getPlugin(*pluginName, options));
std::shared_ptr<Plugin> plugin = etiss::getPlugin(*pluginName, options);
if (!plugin)
etiss::log(etiss::FATALERROR, "Plugin not found: " + *pluginName + "\n");
cpu->addPlugin(plugin);
}
}
if (!po_simpleIni)
Expand Down Expand Up @@ -658,7 +661,10 @@ void etiss::Initializer::loadIniPlugins(std::shared_ptr<etiss::CPUCore> cpu)
etiss::log(etiss::WARNING, "Multiple values for option. Took only last one!");
}
}
cpu->addPlugin(etiss::getPlugin(pluginName, options));
std::shared_ptr<Plugin> plugin = etiss::getPlugin(pluginName, options);
if (!plugin)
etiss::log(etiss::FATALERROR, "Plugin not found: " + pluginName + "\n");
cpu->addPlugin(plugin);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/ETISSInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,14 @@ void etiss::preloadLibraries()
loadLibraryList(installDir() + "/lib/plugins");

// load libraries from user folder
std::string etiss_path = etiss::cfg().get<std::string>("etiss_wd", "");
std::string etiss_path = etiss::cfg().get<std::string>("etiss_wd", ".");
std::vector<std::string> lib_dirs{ std::string("ArchImpl"), std::string("JITImpl"), std::string("PluginImpl") };
if (!etiss_path.empty())
{
std::vector<std::string> libs;
for (auto itr = lib_dirs.begin(); itr != lib_dirs.end(); ++itr)
{
findLibs(boost::filesystem::path(etiss_path + *itr), libs);
findLibs(boost::filesystem::path(etiss_path) / *itr, libs);
}
for (auto itr = libs.begin(); itr != libs.end(); ++itr)
{
Expand Down