Skip to content

Commit

Permalink
adding cpack and making easy the execution and starting of the app. d…
Browse files Browse the repository at this point in the history
…irectly to dev
  • Loading branch information
agustin committed Nov 3, 2020
1 parent 10b59db commit 1c8ed8b
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 68 deletions.
82 changes: 68 additions & 14 deletions install_targets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
# the /usr/bin for now




# check the default destination folder
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# TODO: check on windows?
if(WIN32)
set(USER_HOME_DIR "C:/alias/")
else(WIN32)
Expand Down Expand Up @@ -41,19 +38,22 @@ set(INSTALL_TARGETS_LIBS_LIST
protos
storage
service
qt_client
)

if (UNIX)
set(INSTALL_TARGETS_LIBS_LIST ${INSTALL_TARGETS_LIBS_LIST} uuid)
endif(UNIX)

install(TARGETS ${INSTALL_TARGETS_LIBS_LIST} DESTINATION app)
# libraries
install(TARGETS ${INSTALL_TARGETS_LIBS_LIST} DESTINATION / COMPONENT libraries)

# applicationes
install(TARGETS qt_client DESTINATION / COMPONENT applications)


# TODO: add the post install target to copy the third party libs (all the deps folder
# into the destination folder?
# install(CODE "cp -rf ${ALIAS_DEP_ROOT}/lib/*.so ${CMAKE_INSTALL_PREFIX}/app")
# install(CODE "cp -rf ${ALIAS_DEP_ROOT}/lib/*.so /")

if(WIN32)
##
Expand All @@ -72,12 +72,12 @@ if(WIN32)
set(full_lib_path "${ROOT_FOLDER}/${the_lib}.dll")
set(full_list_files ${full_list_files} ${full_lib_path})
endforeach()
install(FILES ${full_list_files} DESTINATION "${DEST_INSTALL_BIN_PATH}/")
install(FILES ${full_list_files} DESTINATION / COMPONENT libraries)
endfunction()

# we need to copy all the dependencies libs from the bin folder
install(DIRECTORY ${ALIAS_DEP_ROOT}/bin/ DESTINATION ${DEST_INSTALL_BIN_PATH}
FILES_MATCHING PATTERN "*.dll")
install(DIRECTORY ${ALIAS_DEP_ROOT}/bin/ DESTINATION /
COMPONENT libraries FILES_MATCHING PATTERN "*.dll" )

# we need to install qt dependencies
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
Expand All @@ -92,14 +92,68 @@ if(WIN32)
copy_libs("${MINGW64_ROOT}/bin" MINGW_DEP_LIBS)

else(WIN32)
install(DIRECTORY ${ALIAS_DEP_ROOT}/lib/ DESTINATION ${DEST_INSTALL_BIN_PATH}
FILES_MATCHING PATTERN "*.so*")
install(DIRECTORY ${ALIAS_DEP_ROOT}/lib/ DESTINATION /
COMPONENT libraries FILES_MATCHING PATTERN "*.so*")
endif(WIN32)

# Install the folder where we will install the configuration data
if(WIN32)
set(DEST_INSTALL_DATA_PATH "C:/Users/$ENV{USERNAME}/alias")
else(WIN32)
set(DEST_INSTALL_DATA_PATH $ENV{HOME}/alias)
endif(WIN32)


# install the config file
install(FILES "${ROOT_PROJECT_DIR}/resources/config/init.json" DESTINATION ${CMAKE_INSTALL_PREFIX}/)
install(FILES "${ROOT_PROJECT_DIR}/resources/config/init.json" DESTINATION / COMPONENT libraries)


##
## CPACK macros below here
##

set (CPACK_PACKAGE_NAME "alias")
set (CPACK_PACKAGE_VENDOR "agudpp")
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "the tagging content tool")
set (CPACK_PACKAGE_VERSION "0.0.1")
set (CPACK_PACKAGE_VERSION_MAJOR "0")
set (CPACK_PACKAGE_VERSION_MINOR "0")
set (CPACK_PACKAGE_VERSION_PATCH "1")
set (CPACK_PACKAGE_INSTALL_DIRECTORY "alias")

# Define components and their display names
set (CPACK_COMPONENTS_ALL applications libraries)
set (CPACK_COMPONENT_APPLICATIONS_DISPLAY_NAME "Alias app")
set (CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Required libraries")
#set (CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ Headers")

# Human readable component descriptions
set (CPACK_COMPONENT_APPLICATIONS_DESCRIPTION
"Alias qt client app")
set (CPACK_COMPONENT_LIBRARIES_DESCRIPTION
"Required libraries to run qt client app")
#set (CPACK_COMPONENT_HEADERS_DESCRIPTION
# "C/C++ header files for use with MyLib")

# Define dependencies between components
set (CPACK_COMPONENT_APPLICATIONS_DEPENDS libraries)

# Define groups
set(CPACK_COMPONENT_APPLICATIONS_GROUP "Runtime")
set(CPACK_COMPONENT_LIBRARIES_GROUP "Runtime")
#set(CPACK_COMPONENT_HEADERS_GROUP "Development")

set(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION
"All of the tools you'll ever need to develop software")

# Define NSIS installation types
set(CPACK_ALL_INSTALL_TYPES Full)
set(CPACK_COMPONENT_LIBRARIES_INSTALL_TYPES Full)
#set(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full)
set(CPACK_COMPONENT_APPLICATIONS_INSTALL_TYPES Full)

# Must be after the last CPACK macros
include(CPack)

# create the storage empty folder
install(DIRECTORY DESTINATION ${CMAKE_INSTALL_PREFIX}/storage)


74 changes: 20 additions & 54 deletions src/qt_client/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,65 +29,14 @@ struct Params {




//// TODO: remove this test

//static data::Content::Ptr
//createTextContent(const std::string& content, const std::set<data::Tag::ConstPtr>& tags)
//{
// data::Content::Ptr result(new data::Content);
// data::Metadata metadata;
// metadata.setType(data::ContentType::TEXT);
// result->setMetadata(metadata);
// result->setData(content);

// for (auto& tag : tags) {
// result->addTag(tag->id());
// }

// return result;
//}

//static service::ServiceAPI::Ptr
//buildTestService(std::vector<data::Content::Ptr>& contents)
//{
// std::vector<std::string> tag_names = {
// "tag1",
// "tag11",
// "some-other-tag",
// "reliquid"
// };
// data::DataMapper::Ptr data_mapper(new data::DataMapper);
// for (auto& tag_name : tag_names) {
// data::Tag::Ptr tag_ptr(new data::Tag(tag_name));
// data_mapper->addTag(tag_ptr);
// }

// data::Content::Ptr c1 = createTextContent("content number 1", {data_mapper->tagFromName("tag1")});
// data::Content::Ptr c2 = createTextContent("content number 2", {
// data_mapper->tagFromName("tag1"),
// data_mapper->tagFromName("reliquid"),
// });
// data_mapper->addContent(c1);
// data_mapper->addContent(c2);

// contents.push_back(c1);
// contents.push_back(c2);

// storage::DataStorage::Ptr data_storage(new storage::DummyStorage());
// return service::ServiceAPI::Ptr(new service::ServiceAPI(data_mapper, data_storage));
//}



/**
* @brief Returns the default config file path if none is set
* @return the default config file path if none is set
*/
static std::string
getDefaultConfigFilePath()
{
return toolbox::OSHelper::getHomeDir() + "alias/init.json";
{
return toolbox::OSHelper::normalizeFilePath(toolbox::OSHelper::currentWorkingDir(), "init.json");
}

/**
Expand Down Expand Up @@ -123,6 +72,20 @@ buildFileStorage(const std::string& storage_location, data::DataMapper::Ptr& dat
return result;
}

/**
* @brief createFolderIfNotExists
* @param path the path to create
* @return true on success | false otherwise
*/
static bool
createFolderIfNotExists(const std::string& path)
{
if (toolbox::OSHelper::checkFolderExists(path)) {
return true;
}
return toolbox::OSHelper::createFolder(path, true);
}

/**
* @brief buildServiceAPI
* @param config
Expand Down Expand Up @@ -152,7 +115,10 @@ buildServiceAPI(const toolbox::Config& config)
LOG_ERROR("Missing folder value on the config");
return result;
}
data_storage = buildFileStorage(toolbox::OSHelper::expandFilePath(storage_location), data_mapper);
// check if the folder exists otherwise we create it
storage_location = toolbox::OSHelper::expandFilePath(storage_location);
createFolderIfNotExists(storage_location);
data_storage = buildFileStorage(storage_location, data_mapper);
}


Expand Down
13 changes: 13 additions & 0 deletions src/toolbox/include/toolbox/os/os_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ checkFileExists(const std::string& path);
inline std::string
getHomeDir(void);

/**
* @brief Returns the current working directory (PWD)
* @return the current working directory
*/
inline std::string
currentWorkingDir();

/**
* @brief Executes a given command / binary with arguments
* @param command the command / binary to execute
Expand Down Expand Up @@ -200,6 +207,12 @@ getHomeDir(void)
return normalizeFolder(result);
}

inline std::string
currentWorkingDir()
{
return std::filesystem::current_path().string();
}

inline bool
getEnvVar(const std::string& env_var_name, std::string& result)
{
Expand Down

0 comments on commit 1c8ed8b

Please sign in to comment.