Last active
December 25, 2017 15:45
-
-
Save doleron/511c86a880310d2c33825cbdf670901e to your computer and use it in GitHub Desktop.
Bash script to import CMake project from Github and create local Eclipse CDT compatible project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
################################################################################################### | |
# Bash script to import CMake project from Github and create local Eclipse CDT compatible project # | |
# # | |
# The CMake Eclipse CDT strategy was taken from here: https://stackoverflow.com/a/9663686/3055724 # | |
# After run this script you need to import the project in eclipse: # | |
# File->Import->C/C++->Existing code as Makefile Project->Next # | |
# Tested in Eclise Oxygen and Luna # | |
################################################################################################### | |
project_name=MyProject | |
workspace_path=/home/myuser/myworkspace | |
git_url=https://github.com/anuser/repo_name.git | |
if [ ! -d "$workspace_path" ]; then | |
echo "workspace directory $workspace_path not found. Exiting." | |
exit 1 | |
fi | |
project_path=$workspace_path/$project_name | |
if [ -d "$project_path" ]; then | |
echo "the directory $project_path already exists. Exiting." | |
exit 1 | |
fi | |
mkdir $project_path | |
if [ $? -ne 0 ] ; then | |
echo "I couldn't create $project_path dir. Exiting." | |
exit 1 | |
fi | |
mkdir $project_path/src | |
git clone $git_url $project_path/src/$project_name | |
if [ $? -ne 0 ] ; then | |
echo "I couldn't clone $git_url repository. Exiting." | |
exit 1 | |
fi | |
mkdir $project_path/project | |
mkdir $project_path/project/$project_name | |
current_dir=$PWD | |
cd $project_path/project/$project_name | |
cmake ../../src/$project_name -G"Eclipse CDT4 - Unix Makefiles" | |
if [ $? -ne 0 ] ; then | |
echo "I couldn't run cmake for the path $project_path/src/$project_name. Exiting." | |
cd $current_dir | |
exit 1 | |
fi | |
cd $current_dir | |
# remove this line | |
#rm -rf $project_path | |
echo "It is done! Project $project_name successfuly configured." | |
echo "Now, open eclipse and File->Import->C/C++->Existing code as Makefile Project->Next" | |
echo "In \"Existing Code Location\" fill with $project_path/project/$project_name" | |
echo "Also make sure that the option \"Linux GCC\" is selected into \"Toolchain for Index Settings\" list." | |
echo "Click Finish and enjoy your project" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment