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

Add standalone executable #250

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3c93e6c
Add standalone executable
ahcorde Jul 13, 2021
4710cdb
improvements
ahcorde Jul 16, 2021
5be5998
Fixed path windows
ahcorde Jul 19, 2021
c40195d
Fixed CMakelist.txt
ahcorde Jul 19, 2021
bce242e
Fixed CMakelist.txt
ahcorde Jul 19, 2021
246217e
Fixed windows build!
ahcorde Jul 20, 2021
738e789
Merge remote-tracking branch 'origin/ign-gui5' into ahcorde/5/standalone
ahcorde Jul 20, 2021
500f86a
Fixed linux build
ahcorde Jul 20, 2021
d6b491c
fix windows
ahcorde Jul 20, 2021
f5418cc
find ignition-tools
ahcorde Jul 20, 2021
6470807
attemp to fix windows
ahcorde Jul 20, 2021
14641f2
another attemp
ahcorde Jul 20, 2021
8fe9843
another attemp
ahcorde Jul 20, 2021
70800c9
another attemp
ahcorde Jul 20, 2021
d13277a
another attemp
ahcorde Jul 20, 2021
ce069a4
Update CMakeLists.txt
ahcorde Jul 21, 2021
bd8d974
QT_QPA_PLATFORM
ahcorde Jul 21, 2021
d102084
QT_QPA_PLATFORM
ahcorde Jul 21, 2021
17fb711
QT_QPA_PLATFORM
ahcorde Jul 21, 2021
98ca47a
standalone test
ahcorde Jul 21, 2021
a9b4e26
update
ahcorde Jul 21, 2021
eb57c5f
update
ahcorde Jul 21, 2021
4e87255
Revert changes to installed ign.hh
scpeters Aug 16, 2021
3b0a96b
Reverse logic for env delimiter
scpeters Aug 16, 2021
e1a1db3
Merge branch 'ign-gui5' into ahcorde/5/standalone
scpeters Aug 16, 2021
c06f27c
gui_main: include both ign.hh headers
scpeters Aug 16, 2021
f2906b4
src/CMakeLists.txt: extensions for test sources
scpeters Aug 16, 2021
ced10f4
ign.cc: fix includes
scpeters Aug 16, 2021
1081654
Fixed Windows build
ahcorde Aug 24, 2021
be6873d
Fixed build
ahcorde Aug 24, 2021
93d3067
Refactor cmake code, run test without install
scpeters Nov 19, 2021
fbee59a
Merge remote-tracking branch 'origin/ign-gui5' into ahcorde/5/standalone
scpeters Nov 19, 2021
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
13 changes: 7 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ if (ignition-tools_FOUND)
set (HAVE_IGN_TOOLS TRUE)
endif()

#--------------------------------------
# Find ignition-utils
ign_find_package(ignition-utils1 REQUIRED COMPONENTS cli)
set(IGN_UTILS_VER ${ignition-utils1_VERSION_MAJOR})

#--------------------------------------
# Find QT
ign_find_package (Qt5
Expand All @@ -82,8 +87,9 @@ ign_find_package (Qt5
Quick
QuickControls2
Widgets
Qml
REQUIRED
PKGCONFIG "Qt5Core Qt5Quick Qt5QuickControls2 Qt5Widgets"
PKGCONFIG "Qt5Core Qt5Quick Qt5Qml Qt5QuickControls2 Qt5Widgets"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, why is this needed?

)

set(IGNITION_GUI_PLUGIN_INSTALL_DIR
Expand All @@ -95,11 +101,6 @@ set(IGNITION_GUI_PLUGIN_INSTALL_DIR
#============================================================================
ign_configure_build(QUIT_IF_BUILD_ERRORS)

#============================================================================
# ign command line support
#============================================================================
add_subdirectory(conf)

#============================================================================
# Create package information
#============================================================================
Expand Down
20 changes: 0 additions & 20 deletions conf/CMakeLists.txt

This file was deleted.

21 changes: 18 additions & 3 deletions src/Application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,17 @@ bool Application::LoadPlugin(const std::string &_filename,
// Add default folder and install folder
std::string home;
common::env(IGN_HOMEDIR, home);
systemPaths.AddPluginPaths(home + "/.ignition/gui/plugins:" +
IGN_GUI_PLUGIN_INSTALL_DIR);

#ifndef _WIN32
std::string delimiter = ":";
#else
std::string delimiter = ";";
#endif

systemPaths.AddPluginPaths(
common::joinPaths(home, ".ignition", "gui", "plugins") +
delimiter +
IGN_GUI_PLUGIN_INSTALL_DIR);

auto pathToLib = systemPaths.FindSharedLibrary(_filename);
if (pathToLib.empty())
Expand Down Expand Up @@ -577,7 +586,7 @@ std::vector<std::pair<std::string, std::vector<std::string>>>
// 3. ~/.ignition/gui/plugins
std::string home;
common::env(IGN_HOMEDIR, home);
paths.push_back(home + "/.ignition/gui/plugins");
paths.push_back(common::joinPaths(home, ".ignition", "gui", "plugins"));

// 4. Install path
paths.push_back(IGN_GUI_PLUGIN_INSTALL_DIR);
Expand All @@ -598,8 +607,14 @@ std::vector<std::pair<std::string, std::vector<std::string>>>
// All we verify is that the file starts with "lib", any further
// checks would require loading the plugin.

#ifdef _WIN32
if (plugin.find(".lib") != std::string::npos)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking if you meant to use the .lib or if we should use the .dll

#else
if (plugin.find("lib") == 0)
#endif
{
ps.push_back(plugin);
}
}

plugins.push_back(std::make_pair(path, ps));
Expand Down
2 changes: 0 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ set (sources
${CMAKE_CURRENT_SOURCE_DIR}/Dialog.cc
${CMAKE_CURRENT_SOURCE_DIR}/DragDropModel.cc
${CMAKE_CURRENT_SOURCE_DIR}/Helpers.cc
${CMAKE_CURRENT_SOURCE_DIR}/ign.cc
${CMAKE_CURRENT_SOURCE_DIR}/MainWindow.cc
${CMAKE_CURRENT_SOURCE_DIR}/PlottingInterface.cc
${CMAKE_CURRENT_SOURCE_DIR}/Plugin.cc
Expand All @@ -20,7 +19,6 @@ set (gtest_sources
DragDropModel_TEST
Helpers_TEST
GuiEvents_TEST
ign_TEST
MainWindow_TEST
PlottingInterface_TEST
Plugin_TEST
Expand Down
9 changes: 8 additions & 1 deletion src/MainWindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ MainWindow::MainWindow()
return;
}

App()->setWindowIcon(QIcon(":/qml/images/ignition_logo_50x50.png"));
App()->setWindowIcon(QIcon(
common::joinPaths(
":", "qml", "images", "ignition_logo_50x50.png").c_str()));
}

/////////////////////////////////////////////////
Expand All @@ -103,8 +105,13 @@ QStringList MainWindow::PluginListModel() const
{
for (auto const &plugin : path.second)
{
#ifndef _WIN32
// Remove lib and .so
auto pluginName = plugin.substr(3, plugin.find(".") - 3);
#else
// Remove lib and .dll
auto pluginName = plugin.substr(0, plugin.find("."));
#endif

// Split WWWCamelCase3D -> WWW Camel Case 3D
std::regex reg("(\\B[A-Z][a-z])|(\\B[0-9])");
Expand Down
194 changes: 185 additions & 9 deletions src/cmd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,189 @@
# Generate a the ruby script.
# Collect source files into the "sources" variable and unit test files into the
# "gtest_sources" variable.
ign_get_libsources_and_unittests(sources gtest_sources)

add_library(ign STATIC ign.cc)
target_include_directories(ign PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(ign PUBLIC
${PROJECT_LIBRARY_TARGET_NAME}
ignition-common${IGN_COMMON_VER}::ignition-common${IGN_COMMON_VER}
)

set(gui_executable ign-gui)
add_executable(${gui_executable} gui_main.cc)
target_link_libraries(${gui_executable}
ign
ignition-utils${IGN_UTILS_VER}::cli
ignition-common${IGN_COMMON_VER}::ignition-common${IGN_COMMON_VER}
)

install(
TARGETS
${gui_executable}
DESTINATION
${IGN_LIB_INSTALL_DIR}/ignition/${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}/
)

# Build the unit tests.
ign_build_tests(TYPE UNIT SOURCES ${gtest_sources}
TEST_LIST test_list
LIB_DEPS
${EXTRA_TEST_LIB_DEPS}
ignition-common${IGN_COMMON_VER}::ignition-common${IGN_COMMON_VER}
)

foreach(test ${test_list})
target_link_libraries(${test} ign)

# Inform each test of its output directory so it knows where to call the
# auxiliary files from. Using a generator expression here is useful for
# multi-configuration generators, like Visual Studio.
target_compile_definitions(${test} PRIVATE
"DETAIL_IGN_TRANSPORT_TEST_DIR=\"$<TARGET_FILE_DIR:${test}>\""
"IGN_TEST_LIBRARY_PATH=\"$<TARGET_FILE_DIR:${PROJECT_LIBRARY_TARGET_NAME}>\"")

endforeach()

#===============================================================================
# Used for the installed version.
# Generate the ruby script that gets installed.
# Note that the major version of the library is included in the name.
if (APPLE)
set(IGN_LIBRARY_NAME lib${PROJECT_NAME_LOWER}.dylib)
else()
set(IGN_LIBRARY_NAME lib${PROJECT_NAME_LOWER}.so)
endif()
# Ex: cmdgui5.rb
set(cmd_script_generated "${CMAKE_CURRENT_BINARY_DIR}/cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.rb")
set(cmd_script_configured "${cmd_script_generated}.configured")

# Set the library_location variable to the relative path to the library file
# within the install directory structure.
set(gui_exe_location "../../../${CMAKE_INSTALL_LIBDIR}/ignition/${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}/$<TARGET_FILE_NAME:${gui_executable}>")

configure_file(
"cmdgui.rb.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmdgui${PROJECT_VERSION_MAJOR}.rb" @ONLY)
"cmd${IGN_DESIGNATION}.rb.in"
"${cmd_script_configured}"
@ONLY)

file(GENERATE
OUTPUT "${cmd_script_generated}"
INPUT "${cmd_script_configured}")

#Used for the installed version.
set(ign_library_path "${CMAKE_INSTALL_PREFIX}/lib/ruby/ignition/cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}")

# Generate the configuration file that is installed.
# Note that the major version of the library is included in the name.
# Ex: gui5.yaml
configure_file(
"${IGN_DESIGNATION}.yaml.in"
"${CMAKE_CURRENT_BINARY_DIR}/${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.configure.yaml" @ONLY)

file(GENERATE
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.yaml"
INPUT "${CMAKE_CURRENT_BINARY_DIR}/${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.configure.yaml")

# Install the yaml configuration files in an unversioned location.
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.yaml
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/ignition/)

# Install the ruby command line library in an unversioned location.
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmdgui${PROJECT_VERSION_MAJOR}.rb DESTINATION lib/ruby/ignition)
install(FILES ${cmd_script_generated} DESTINATION lib/ruby/ignition)

if (TARGET UNIT_ign_TEST)
# Generate the ruby script for internal testing.
# Note that the major version of the library is included in the name.
# Ex: cmdgui5.rb
set(cmd_script_generated_test "${CMAKE_BINARY_DIR}/test/$<CONFIG>/lib/ruby/ignition/cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.rb")
set(cmd_script_configured_test "${CMAKE_CURRENT_BINARY_DIR}/test_cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.rb.configured")

# Set the library_location variable to the full path of the library file within
# the build directory.
set(gui_exe_location "$<TARGET_FILE:${gui_executable}>")

configure_file(
"cmd${IGN_DESIGNATION}.rb.in"
"${cmd_script_configured_test}"
@ONLY
)

file(GENERATE
OUTPUT "${cmd_script_generated_test}"
INPUT "${cmd_script_configured_test}"
)
# Generate a configuration file for internal testing.
# Note that the major version of the library is included in the name.
# Ex: gui5.yaml
configure_file(
"${IGN_DESIGNATION}.yaml.in"
"${CMAKE_CURRENT_BINARY_DIR}/${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.yaml.configured" @ONLY)

# Used for the installed version.
set(ign_library_path "${CMAKE_INSTALL_PREFIX}/lib/ruby/ignition/cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.rb")

file(GENERATE
OUTPUT "${CMAKE_BINARY_DIR}/test/conf/$<CONFIG>/${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.yaml"
INPUT "${CMAKE_CURRENT_BINARY_DIR}/${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.yaml.configured")

set(_env_vars)
if(WIN32)
list(APPEND _env_vars "PATH=${CMAKE_INSTALL_PREFIX}/bin;$ENV{PATH}")
endif()
list(APPEND _env_vars "IGN_CONFIG_PATH=${CMAKE_BINARY_DIR}/test/conf/$<CONFIG>")

set_tests_properties(
UNIT_ign_TEST
PROPERTIES
ENVIRONMENT
"${_env_vars}"
)
endif()

if(Qt5_FOUND AND WIN32 AND TARGET Qt5::qmake AND NOT TARGET Qt5::windeployqt)
get_target_property(_qt5_qmake_location
Qt5::qmake IMPORTED_LOCATION
)

execute_process(
COMMAND "${_qt5_qmake_location}" -query QT_INSTALL_PREFIX
RESULT_VARIABLE return_code
OUTPUT_VARIABLE qt5_install_prefix
OUTPUT_STRIP_TRAILING_WHITESPACE
)

# Anaconda3 Location
set(imported_location "${qt5_install_prefix}/bin/windeployqt.exe")
# vcpkg location
set(imported_location2 "${qt5_install_prefix}/tools/qt5/bin/windeployqt.exe")

if(EXISTS ${imported_location})
set(QML_DIR ${qt5_install_prefix}/qml)
add_executable(Qt5::windeployqt IMPORTED)

set_target_properties(Qt5::windeployqt PROPERTIES
IMPORTED_LOCATION ${imported_location}
)
elseif(EXISTS ${imported_location2})
set(QML_DIR ${qt5_install_prefix}/qml)
add_executable(Qt5::windeployqt IMPORTED)

set_target_properties(Qt5::windeployqt PROPERTIES
IMPORTED_LOCATION ${imported_location2}
)
else()
message("Not able to locate windeployqt.exe")
endif()
endif()

if(TARGET Qt5::windeployqt)
# execute windeployqt in a tmp directory after build
add_custom_command(TARGET ${gui_executable}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_CURRENT_BINARY_DIR}/windeployqt"
COMMAND set PATH=%PATH%$<SEMICOLON>${qt5_install_prefix}/bin
COMMAND Qt5::windeployqt --dir "${CMAKE_CURRENT_BINARY_DIR}/windeployqt" --qmldir ${QML_DIR} ${CMAKE_BINARY_DIR}/bin/$<CONFIG>/ign-gui.exe --quick --qml
)

# copy deployment directory during installation
install(
DIRECTORY
"${CMAKE_CURRENT_BINARY_DIR}/windeployqt/"
DESTINATION ${IGN_LIB_INSTALL_DIR}/ignition/${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}/
)
endif()
Loading