Skip to content
Snippets Groups Projects
Commit 9ade00bc authored by Fernando Herrero's avatar Fernando Herrero
Browse files

Merge branch 'install_path' into 'master'

Install path

See merge request !1
parents 41a7d599 4f8ab56a
No related branches found
No related tags found
1 merge request!1Install path
bin
build
lib
\ No newline at end of file
image: docker.io/labrobotica/labrobotica
variables:
GIT_SUBMODULE_STRATEGY: recursive
stages:
- build
- test
- deploy
build-package:
stage: build
script:
#- git submodule sync --recursive
#- git submodule update --init --recursive
- apt update
##Install dependencies
#- apt -y install iri-dep1-dev iri-dep2-dev
- mkdir -pv build
- cd build
- cmake -DCMAKE_BUILD_TYPE=RELEASE -DCPACK_PACKAGE_VERSION=$CI_COMMIT_TAG ..
- make package -j $(nproc)
artifacts:
paths:
- build/*.deb
expire_in: 2 weeks
only:
- tags
update_repo:
stage: deploy
script:
- cd build
- "scp -i /root/.ssh/iriLabKeyNopwd -r *library-name*.deb irilabo@labrepo.iri.upc.edu:packages/"
- "ssh irilabo@labrepo.iri.upc.edu -i /root/.ssh/iriLabKeyNopwd -tt /home/irilabo/repo_scripts/update_repo.sh library-name"
only:
- tags
\ No newline at end of file
......@@ -9,6 +9,7 @@ endif(COMMAND cmake_policy)
# The project name and the type of project
PROJECT(project_name)
SET(PACKAGE_NAME project-name)
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib)
......@@ -55,6 +56,8 @@ IF (UNIX)
ADD_CUSTOM_COMMAND(
COMMENT "uninstall package"
COMMAND xargs ARGS rm < install_manifest.txt
COMMAND rm -rd ${CMAKE_INSTALL_PREFIX}/lib/iri/${PROJECT_NAME}
COMMAND rm -rd ${CMAKE_INSTALL_PREFIX}/include/iri/${PROJECT_NAME}
TARGET uninstall
)
......@@ -65,4 +68,24 @@ ELSE(UNIX)
)
ENDIF(UNIX)
IF (UNIX)
SET(CPACK_PACKAGE_FILE_NAME "iri-${PACKAGE_NAME}-dev-${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
SET(CPACK_PACKAGE_NAME "iri-${PACKAGE_NAME}-dev")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Part of IRI-laboratory libraries. More information at https://gitlab.iri.upc.edu/labrobotica")
SET(CPACK_PACKAGING_INSTALL_PREFIX /usr)
SET(CPACK_GENERATOR "DEB")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "labrobotica - labrobotica@iri.upc.edu")
#Uncomment to add the necessary mantainer scripts
#SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/scripts/debian/preinst;${CMAKE_SOURCE_DIR}/scripts/debian/postinst;${CMAKE_SOURCE_DIR}/scripts/debian/prerm;${CMAKE_SOURCE_DIR}/scripts/debian/postrm")
#Uncomment to add dependencies comma separated
#SET(CPACK_DEBIAN_PACKAGE_DEPENDS "iri-dep1-dev (>= 1.0~${DISTRIB}), iri-dep2-dev (>= 1.0~${DISTRIB})")
INCLUDE(CPack)
ELSE(UNIX)
ADD_CUSTOM_COMMAND(
COMMENT "packaging only implemented in unix"
TARGET uninstall
)
ENDIF(UNIX)
\ No newline at end of file
#edit the following line to add the librarie's header files
FIND_PATH(library_name_INCLUDE_DIR header_file /usr/include/iridrivers /usr/local/include/iridrivers)
SET(name library_name)
FIND_PATH(${name}_INCLUDE_DIRS ${name}.h /usr/local/include/iri/${name} /usr/include/iri/${name})
FIND_LIBRARY(library_name_LIBRARY
NAMES library_name
PATHS /usr/lib /usr/local/lib /usr/local/lib/iridrivers)
FIND_LIBRARY(${name}_LIBRARIES
NAMES ${name}
PATHS /usr/local/lib/iri/${name} /usr/lib/iri/${name})
SET(${name}_INCLUDE_DIR ${${name}_INCLUDE_DIRS})
SET(${name}_LIBRARY ${${name}_LIBRARIES})
IF (library_name_INCLUDE_DIR AND library_name_LIBRARY)
SET(library_name_FOUND TRUE)
ENDIF (library_name_INCLUDE_DIR AND library_name_LIBRARY)
IF (library_name_FOUND)
IF (NOT library_name_FIND_QUIETLY)
MESSAGE(STATUS "Found library_name: ${library_name_LIBRARY}")
ENDIF (NOT library_name_FIND_QUIETLY)
ELSE (library_name_FOUND)
IF (library_name_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find library_name")
ENDIF (library_name_FIND_REQUIRED)
ENDIF (library_name_FOUND)
IF (${name}_INCLUDE_DIRS AND ${name}_LIBRARIES)
SET(${name}_FOUND TRUE)
ENDIF (${name}_INCLUDE_DIRS AND ${name}_LIBRARIES)
IF (${name}_FOUND)
IF (NOT ${name}_FIND_QUIETLY)
MESSAGE(STATUS "Found ${name}: ${${name}_LIBRARIES}")
ENDIF (NOT ${name}_FIND_QUIETLY)
ELSE (${name}_FOUND)
IF (${name}_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find ${name}")
ENDIF (${name}_FIND_REQUIRED)
ENDIF (${name}_FOUND)
\ No newline at end of file
LICENSE 0 → 100644
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
......@@ -22,23 +22,23 @@ Clone the repository to the desired location.
Execute the *new_project.sh* script with the following parameters:
* **-t project\_type**: this parameter is required. It specifies which kind of project is to be created. At the moment, only two project types types are allowed:
* *library*: generates the necessary structure to create a shared library that can be used in other driver or applications.
* *application*: generates the necessary structure to create a binary file.
* **-p project\_description**: this parameter is required. It provides a short description of the project. This parameter will appear in all the associated documentation. For multi-word values, use the double quote.
* *library*: generates the necessary structure to create a shared library that can be used in other driver or applications.
* *application*: generates the necessary structure to create a binary file.
* **-p "the project description"**: this parameter is required. It provides a short description of the project. This parameter will appear in all the associated documentation. For multi-word values, use the double quote.
* **-n project\_name**: this parameter is required. It specifies the name of the shared library or the binary file to be generate by the project. **This parameter must not have any whitespace characters**.
* **-d comma,separated,dependencies**: this parameter is optional. It specifies a set of dependencies of the library or application being generated. These depedencies will be automatically included inside the CMake structure. Only dependencies developed at IRI are currently supported. Other type of dependencies should better be added by hand.
* **-d comma\_separated\_dependencies**: this parameter is optional. It specifies a set of dependencies of the library or application being generated. These depedencies will be automatically included inside the CMake structure. Only dependencies supported by the CMake framework are currently supported.
[//]: <> (Commented test option until it is operative again)
[//]: <> (* **-g**: this parameters is optional. Is specifies whether the test strcture is to be included into the project or not. This includes the necessaty CMake files to download and locally build the google test software and a basic test file for the generated project.)
* **-g**: this parameters is optional. Is specifies whether the test strcture is to be included into the project or not. This includes the necessaty CMake files to download and locally build the google test software and a basic test file for the generated project.
After executing the script, all the temporary and template files are removed, as well as the link to the remote GIT repository, so that the new project can be easily associated to another repository.
After executing the script, all the temporary and template files are removed, as well as the link to the remote GIT repository, so that the new project can be easily associated to another repository.
Finally you can rename the main folder as your project_name.
## Disclaimer
Copyright (C) 2009-2018 Institut de Robòtica i Informàtica Industrial, CSIC-UPC.
Mantainer author_name (author_email)
Copyright (C) Institut de Robòtica i Informàtica Industrial, CSIC-UPC.
Mantainer labrobotica (labrobotica@iri.upc.edu)
This package is distributed in the hope that it will be useful, but without any warranty. It is provided "as is" without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the program is with you. should the program prove defective, the GMR group does not assume the cost of any necessary servicing, repair or correction.
......
......@@ -5,6 +5,30 @@ project_name {#mainpage}
project_description
## Installation
* Add the labrobotica repository if it is not already added: run the commands on _add repository_ and _add key_ from [labrobotica_how_to installation](https://gitlab.iri.upc.edu/labrobotica/labrobotica_how_to/-/blob/master/README.md#installation)
* Install the package:
sudo apt update && sudo apt install iri-project-name-dev
## Disclaimer
Copyright (C) Institut de Robòtica i Informàtica Industrial, CSIC-UPC.
Mantainer author_name (author_email)
This package is distributed in the hope that it will be useful, but without any warranty. It is provided "as is" without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the program is with you. should the program prove defective, the GMR group does not assume the cost of any necessary servicing, repair or correction.
In no event unless required by applicable law the author will be liable to you for damages, including any general, special, incidental or consequential damages arising out of the use or inability to use the program (including but not limited to loss of data or data being rendered inaccurate or losses sustained by you or third parties or a failure of the program to operate with any other programs), even if the author has been advised of the possibility of such damages.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
## For developers
<details><summary>click here</summary>
<p>
## Dependencies
This package requires of the following system libraries and packages
......@@ -17,26 +41,26 @@ Under linux all of these utilities are available in ready-to-use packages.
Under MacOS most of the packages are available via [fink](http://www.finkproject.org/ "Fink's Homepage")
This package also requires of the following IRI libraries:
This package also requires of the following dependencies:
## Compilation and installation
## Compilation and installation from source
Download this repository and create a build folder inside:
Clone this repository and create a build folder inside:
``` mkdir build ```
mkdir build
Inside the build folder execute the following commands:
``` cmake .. ```
cmake ..
The default build mode is DEBUG. That is, objects and executables include debug information.
The RELEASE build mode optimizes for speed. To build in this mode execute instead
``` cmake .. -DCMAKE_BUILD_TYPE=RELEASE ```
cmake .. -DCMAKE_BUILD_TYPE=RELEASE
The release mode will be kept until next time cmake is executed.
``` make ```
make -j $(nproc)
In case no errors are reported, the generated libraries (if any) will be located at the
_lib_ folder and the executables (if any) will be located at the _bin_ folder.
......@@ -44,45 +68,39 @@ _lib_ folder and the executables (if any) will be located at the _bin_ folder.
In order to be able to use the library, it it necessary to copy it into the system.
To do that, execute
``` make install ```
make install
as root and the shared libraries will be copied to */usr/local/lib/iridrivers* directory
and the header files will be copied to */usr/local/include/iridrivers* dierctory. At
as root and the shared libraries will be copied to */usr/local/lib/iri/project_name* directory
and the header files will be copied to */usr/local/include/iri/project_name* directory. At
this point, the library may be used by any user.
To remove the library from the system, exceute
``` make uninstall ```
make uninstall
as root, and all the associated files will be removed from the system.
To generate the documentation execute the following command:
``` make doc ```
make doc
## How to use it
To use this library in an other library or application, in the CMakeLists.txt file, first it is necessary to locate if the library has been installed or not using the following command
To use this library in another library or application, in the CMakeLists.txt file, first it is necessary to locate if the library has been installed or not using the following command
``` FIND_PACKAGE(project_name) ```
FIND_PACKAGE(project_name)
In the case that the package is present, it is necessary to add the header files directory to the include directory path by using
``` INCLUDE_DIRECTORIES(${project_name_INCLUDE_DIR}) ```
INCLUDE_DIRECTORIES(${project_name_INCLUDE_DIRS})
and it is also necessary to link with the desired libraries by using the following command
``` TARGET_LINK_LIBRARIES(<executable name> ${project_name_LIBRARY}) ```
## Disclaimer
Copyright (C) 2009-2018 Institut de Robòtica i Informàtica Industrial, CSIC-UPC.
Mantainer author_name (author_email)
This package is distributed in the hope that it will be useful, but without any warranty. It is provided "as is" without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the program is with you. should the program prove defective, the GMR group does not assume the cost of any necessary servicing, repair or correction.
TARGET_LINK_LIBRARIES(<executable name> ${project_name_LIBRARIES})
In no event unless required by applicable law the author will be liable to you for damages, including any general, special, incidental or consequential damages arising out of the use or inability to use the program (including but not limited to loss of data or data being rendered inaccurate or losses sustained by you or third parties or a failure of the program to operate with any other programs), even if the author has been advised of the possibility of such damages.
## Examples
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
There are examples that show how to use the different classes.
</p>
</details>
\ No newline at end of file
This diff is collapsed.
#ifndef _LIBRARY_NAME_H
#define _LIBRARY_NAME_H
/**
* @class CLibrary_name
* @brief CLibrary_name class brief description text
* @details CLibrary_name class detailed description text
*
*/
class CLibrary_name
{
public:
......
#! /bin/sh
#! /bin/bash
DEP=
TYPE=
......@@ -6,6 +6,18 @@ PROJECT_DESC=
NAME=
TEST=0
# usage="Usage:
# \tnew_project.sh -t <library/application> -n project_name -p \"project description\" [-d dependency1,dependency2,dependency3][-g]
# Parameters:
# \t-d: comma separated dependencies (optional).
# \t-g: include test structure (optional)."
usage="Usage:
\tnew_project.sh -t <library/application> -n project_name -p \"project description\" [-d dependency1,dependency2,dependency3]
Parameters:
\t-d: comma separated dependencies (optional)."
##\t-g: include test structure (optional).
while getopts “t:p:n:d:g” OPTION
do
case $OPTION in
......@@ -25,7 +37,8 @@ do
TEST=1
;;
?)
echo invalid argument $OPTION
echo "ERROR: invalid argument: $OPTION"
echo "${usage}"
exit
;;
esac
......@@ -36,46 +49,58 @@ case $TYPE in
;;
library) echo Generating a library project ...
;;
*) echo Unknown project type "$TYPE"
exit
*) echo "ERROR: unknown project type: $TYPE"
echo "${usage}"
exit
;;
esac
if [ "$NAME" ]
then
echo "Generating folder structure for project $NAME ..."
case $NAME in
*\ * )
echo "ERROR: project name cannot have whitespaces, aborting..."
exit
;;
*)
echo "Generating folder structure for project $NAME ..."
NAME=$(echo $NAME | tr '[:upper:]' '[:lower:]')
echo "Using library name $NAME ..."
;;
esac
else
echo "No project name provided, aborting ..."
echo "ERROR: No project name provided, aborting..."
echo "${usage}"
exit
fi
if [ $NAME ]
if [ ! "$PROJECT_DESC" ]
then
NAME=$(echo $NAME | tr '[:upper:]' '[:lower:]')
echo "Using library name $NAME ..."
else
echo "No library name provided, aborting ..."
echo "ERROR: No project description provided, aborting..."
echo "${usage}"
exit
fi
#create the bin directory
BIN_DIR="./bin"
if [ -e "$BIN_DIR" ]
then
echo "$BIN_DIR directory already exists, skipping ..."
else
echo "Creating $BIN_DIR directory"
mkdir $BIN_DIR
fi
# create the lib directory
LIB_DIR="./lib"
if [ -e "$LIB_DIR" ]
then
echo "$LIB_DIR directory already exists, skipping ..."
else
echo "Creating $LIB_DIR directory"
mkdir $LIB_DIR
fi
# #create the bin directory
# BIN_DIR="./bin"
# if [ -e "$BIN_DIR" ]
# then
# echo "$BIN_DIR directory already exists, skipping ..."
# else
# echo "Creating $BIN_DIR directory"
# mkdir $BIN_DIR
# fi
# # create the lib directory
# LIB_DIR="./lib"
# if [ -e "$LIB_DIR" ]
# then
# echo "$LIB_DIR directory already exists, skipping ..."
# else
# echo "Creating $LIB_DIR directory"
# mkdir $LIB_DIR
# fi
# create the src directory
SRC_DIR="./src"
if [ -e "$SRC_DIR" ]
......@@ -147,26 +172,55 @@ fi
#parse the dependencies and create the dependencies file
arr=$(echo $DEP | tr "," "\n")
NAME_WITH_DASHES=$(echo $NAME | sed 's/_/-/g')
#Set the author's email on the ReadMe.md disclaimer file
sed 's/author_email/labrobotica@iri.upc.edu/g' <ReadMe_template.md >tmp1.md
#set the author's name on the ReadMe.txt disclaimer file
sed 's/author_name/IRI labrobotics/g' <tmp1.md >tmp2.md
sed 's/author_name/IRI labrobotica/g' <tmp1.md >tmp2.md
#Set the project name on the ReadMe.txt disclaimer file
sed 's/project_description/'"$PROJECT_DESC"'/g' <tmp2.md >tmp3.md
sed 's/project_name/'"$NAME"'/g' <tmp3.md >./ReadMe.md
sed 's/project_name/'"$NAME"'/g' <tmp3.md >tmp4.md
sed 's/project-name/'"$NAME_WITH_DASHES"'/g' <tmp4.md >./ReadMe.md
for x in $arr
do
DEP_LINE=" - $x"
sed -i '/^This package also requires of the following dependencies:/a'"${DEP_LINE}" ./ReadMe.md
done
rm tmp1.md
rm tmp2.md
rm tmp3.md
rm tmp4.md
rm ReadMe_template.md
#Set the project name on the CMakeLists.txt script file
NEW_NAME=$(echo $NAME | sed 's/_/-/g')
if [ $TEST = 1 ]
then
sed 's/project_name/'$NEW_NAME'/g' <CMakeLists_test_template.txt >./CMakeLists.txt
sed 's/project_name/'$NAME'/g' <CMakeLists_test_template.txt >./CMakeLists.txt
else
sed 's/project_name/'$NEW_NAME'/g' <CMakeLists_template.txt >./CMakeLists.txt
sed 's/project_name/'$NAME'/g' <CMakeLists_template.txt >temp1.txt
sed 's/project-name/'$NAME_WITH_DASHES'/g' <temp1.txt >./CMakeLists.txt
rm temp1.txt
fi
#Add to CMakeLists.txt line with dependencies like SET(CPACK_DEBIAN_PACKAGE_DEPENDS "iri-dep1-dev (>= 1.0~${DISTRIB}), iri-dep2-dev (>= 1.0~${DISTRIB})")
if [ -n "$arr" ]
then
cpack_depends="SET(CPACK_DEBIAN_PACKAGE_DEPENDS \""
for x in $arr
do
dep_line="iri-$x-dev (>= 1.0~\${DISTRIB})"
cpack_depends="$cpack_depends$dep_line, "
done
cpack_depends=${cpack_depends%??} #remove last ', '
cpack_depends="$cpack_depends\")"
line_to_add="\ \ $cpack_depends"
file=./CMakeLists.txt
comment="#Uncomment to add dependencies comma separated"
sed -i "/${comment}/ a ${line_to_add}" ${file}
fi
rm CMakeLists_test_template.txt
rm CMakeLists_template.txt
......@@ -175,78 +229,119 @@ sed 's/project_name/'"$NAME"'/g' <doxygen_project_name_template.conf >./doc/doxy
rm doxygen_project_name_template.conf
mv doxygen_template.conf ./doc/doxygen.conf
PROJECT_NAME_VAR="\${PROJECT_NAME}"
#create the CMakeLists.txt script file
if [ $TYPE = application ]
then
echo "# locate the necessary dependencies" >> CMakeLists.tmp
echo "# FIND_PACKAGE(my_example_library REQUIRED)" >> CMakeLists.tmp
for x in $arr
do
echo "FIND_PACKAGE($x REQUIRED)" >> CMakeLists.tmp
done
echo "" >> CMakeLists.tmp
echo "# add the necessary include directories" >> CMakeLists.tmp
echo "INCLUDE_DIRECTORIES(../include)" >> CMakeLists.tmp
for x in $arr
do
echo "INCLUDE_DIRECTORIES("'${'"${x}_INCLUDE_DIR"'}'")" >> CMakeLists.tmp
echo "INCLUDE_DIRECTORIES("'${'"${x}_INCLUDE_DIRS"'}'")" >> CMakeLists.tmp
done
echo "" >> CMakeLists.tmp
echo "# application source files" >> CMakeLists.tmp
echo "SET(sources ${NAME}.cpp)" >> CMakeLists.tmp
echo "SET(sources ${PROJECT_NAME_VAR}.cpp)" >> CMakeLists.tmp
echo "" >> CMakeLists.tmp
echo "# application header files" >> CMakeLists.tmp
echo "SET(headers ../include/${NAME}.h)" >> CMakeLists.tmp
echo "SET(headers ../include/${PROJECT_NAME_VAR}.h)" >> CMakeLists.tmp
echo "" >> CMakeLists.tmp
echo "# create the executable file" >> CMakeLists.tmp
echo "ADD_EXECUTABLE(${NAME} "'${'"sources"'}'")" >> CMakeLists.tmp
echo "ADD_EXECUTABLE(${PROJECT_NAME_VAR} "'${'"sources"'}'")" >> CMakeLists.tmp
echo "" >> CMakeLists.tmp
echo "# link necessary libraries" >> CMakeLists.tmp
echo "#TARGET_LINK_LIBRARIES(${PROJECT_NAME_VAR} \${my_example_library_LIBRARIES})">>CMakeLists.tmp
for x in $arr
do
echo "TARGET_LINK_LIBRARIES(${NAME} "'${'"${x}_LIBRARY"'}'")" >> CMakeLists.tmp
echo "TARGET_LINK_LIBRARIES(${PROJECT_NAME_VAR} "'${'"${x}_LIBRARIES"'}'")" >> CMakeLists.tmp
done
echo "" >> CMakeLists.tmp
echo "#ADD_DEPENDENCIES(${PROJECT_NAME_VAR} my_example_library_target)">>CMakeLists.tmp
mv CMakeLists.tmp ./src/CMakeLists.txt
mv application_src_template.cpp ./src/$NAME.cpp
else
echo "# driver source files" >> CMakeLists.tmp
echo "SET(sources ${NAME}.cpp)" >> CMakeLists.tmp
echo "SET(sources ${PROJECT_NAME_VAR}.cpp)" >> CMakeLists.tmp
echo "" >> CMakeLists.tmp
echo "# application header files" >> CMakeLists.tmp
echo "SET(headers ../include/${NAME}.h)" >> CMakeLists.tmp
echo "SET(headers ../include/${PROJECT_NAME_VAR}.h)" >> CMakeLists.tmp
echo "" >> CMakeLists.tmp
echo "# locate the necessary dependencies" >> CMakeLists.tmp
echo "# FIND_PACKAGE(my_example_library REQUIRED)" >> CMakeLists.tmp
for x in $arr
do
echo "FIND_PACKAGE($x REQUIRED)" >> CMakeLists.tmp
done
echo "" >> CMakeLists.tmp
echo "# add the necessary include directories" >> CMakeLists.tmp
echo "INCLUDE_DIRECTORIES(../include)" >> CMakeLists.tmp
for x in $arr
do
echo "INCLUDE_DIRECTORIES("'${'"${x}_INCLUDE_DIR"'}'")" >> CMakeLists.tmp
echo "INCLUDE_DIRECTORIES("'${'"${x}_INCLUDE_DIRS"'}'")" >> CMakeLists.tmp
done
echo "" >> CMakeLists.tmp
echo "# create the shared library" >> CMakeLists.tmp
echo "ADD_LIBRARY(${NAME} SHARED "'${'"sources"'}'")" >> CMakeLists.tmp
echo "ADD_LIBRARY(${PROJECT_NAME_VAR} SHARED "'${'"sources"'}'")" >> CMakeLists.tmp
echo "" >> CMakeLists.tmp
echo "# link necessary libraries" >> CMakeLists.tmp
echo "#TARGET_LINK_LIBRARIES(${PROJECT_NAME_VAR} \${my_example_library_LIBRARIES})">>CMakeLists.tmp
for x in $arr
do
echo "TARGET_LINK_LIBRARIES(${NAME} "'${'"${x}_LIBRARY"'}'")" >> CMakeLists.tmp
echo "TARGET_LINK_LIBRARIES(${PROJECT_NAME_VAR} "'${'"${x}_LIBRARIES"'}'")" >> CMakeLists.tmp
done
echo "INSTALL(TARGETS $NAME" >> CMakeLists.tmp
echo "" >> CMakeLists.tmp
echo "#ADD_DEPENDENCIES(${PROJECT_NAME_VAR} my_example_library_target)">>CMakeLists.tmp
echo "" >> CMakeLists.tmp
echo "INSTALL(TARGETS $PROJECT_NAME_VAR" >> CMakeLists.tmp
echo " RUNTIME DESTINATION bin" >> CMakeLists.tmp
echo " LIBRARY DESTINATION lib/iridrivers" >> CMakeLists.tmp
echo " ARCHIVE DESTINATION lib/iridrivers)" >> CMakeLists.tmp
echo "INSTALL(FILES "'${'"headers"'}' "DESTINATION include/iridrivers)" >> CMakeLists.tmp
echo "INSTALL(FILES ../Find$NAME.cmake DESTINATION "'${'"CMAKE_ROOT"'}'"/Modules/)" >> CMakeLists.tmp
echo " LIBRARY DESTINATION lib/iri/${PROJECT_NAME_VAR}" >> CMakeLists.tmp
echo " ARCHIVE DESTINATION lib/iri/${PROJECT_NAME_VAR})" >> CMakeLists.tmp
echo "INSTALL(FILES "'${'"headers"'}' "DESTINATION include/iri/${PROJECT_NAME_VAR})" >> CMakeLists.tmp
echo "INSTALL(FILES ../Find$PROJECT_NAME_VAR.cmake DESTINATION "'${'"CMAKE_ROOT"'}'"/Modules/)" >> CMakeLists.tmp
echo "" >> CMakeLists.tmp
echo "#Install script files if needed" >> CMakeLists.tmp
echo "#INSTALL(FILES ../scripts/<script_name> " >> CMakeLists.tmp
echo "# DESTINATION share/iri" >> CMakeLists.tmp
echo "# PERMISSIONS OWNER_EXECUTE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE)" >> CMakeLists.tmp
echo "" >> CMakeLists.tmp
echo "ADD_SUBDIRECTORY(examples)" >> CMakeLists.tmp
mv CMakeLists.tmp ./src/CMakeLists.txt
echo "# create an example application" >> CMakeLists.tmp
echo "ADD_EXECUTABLE(${NAME}_test ${NAME}_test.cpp)" >> CMakeLists.tmp
echo "ADD_EXECUTABLE(${PROJECT_NAME_VAR}_test ${PROJECT_NAME_VAR}_test.cpp)" >> CMakeLists.tmp
echo "# link necessary libraries" >> CMakeLists.tmp
echo "TARGET_LINK_LIBRARIES(${NAME}_test $NAME)" >> CMakeLists.tmp
for x in $arr
do
echo "TARGET_LINK_LIBRARIES(${NAME}_test "'${'"${x}_LIBRARY"'}'")" >> CMakeLists.tmp
done
echo "TARGET_LINK_LIBRARIES(${PROJECT_NAME_VAR}_test $PROJECT_NAME_VAR)" >> CMakeLists.tmp
# for x in $arr
# do
# echo "TARGET_LINK_LIBRARIES(${PROJECT_NAME_VAR}_test "'${'"${x}_LIBRARY"'}'")" >> CMakeLists.tmp
# done
mv CMakeLists.tmp ./src/examples/CMakeLists.txt
sed 's/header_file/'"${NAME}.h"'/g' <Findlib_template.cmake >tmp.cmake
sed 's/library_name/'$NAME'/g' <tmp.cmake >./Find$NAME.cmake
rm tmp.cmake
sed 's/library_name/'$NAME'/g' <Findlib_template.cmake >./Find$NAME.cmake
LIBRARY_NAME=$(echo $NAME | tr '[:lower:]' '[:upper:]')
Library_name=$(echo $NAME | sed 's/\([a-zA-Z]\)\([a-zA-Z0-9]*\)/\u\1\2/g')
......@@ -264,10 +359,27 @@ else
rm application_src_template.cpp
fi
sed 's/library-name/'$NAME_WITH_DASHES'/g' <.gitlab-ci_template.yml >./.gitlab-ci.yml
#Add to .gitlab-ci.yml apt install dependencies like - apt -y install iri-dep1-dev iri-dep2-dev
if [ -n "$arr" ]
then
apt_deps=""
for x in $arr
do
dep_line="iri-$x-dev"
apt_deps="$apt_deps$dep_line "
done
line_to_add="\ \ \ \ \ \ - apt -y install $apt_deps"
file=./.gitlab-ci.yml
comment="##Install dependencies"
sed -i "/${comment}/ a ${line_to_add}" ${file}
fi
if [ $TEST = 1 ]
then
Library_name=$(echo $NAME | sed 's/\([a-zA-Z]\)\([a-zA-Z0-9]*\)/\u\1\2/g')
sed 's/library_name/'$NEW_NAME'/g' <./test/CMakeLists_template.txt >./test/tmp.txt
sed 's/library_name/'$NAME'/g' <./test/CMakeLists_template.txt >./test/tmp.txt
sed 's/Library_name/'$Library_name'/g' <./test/tmp.txt >./test/CMakeLists.txt
rm ./test/CMakeLists_template.txt
rm ./test/tmp.txt
......@@ -281,6 +393,6 @@ rm driver_src_template.cpp
rm driver_header_template.h
rm driver_example_src_template.cpp
rm Findlib_template.cmake
rm template.tar.gz
rm .gitlab-ci_template.yml
rm new_project.sh
rm -rf .git
rm -rf .git
\ No newline at end of file
File deleted
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment