Commit a5994926 authored by Lennart Nachtigall's avatar Lennart Nachtigall
Browse files

init commit- software should work

parents

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cmake-Project-Generator", "Cmake-Project-Generator\Cmake-Project-Generator.csproj", "{58FE24D7-ED03-46B5-8F3E-3E52AF821089}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{58FE24D7-ED03-46B5-8F3E-3E52AF821089}.Debug|x86.ActiveCfg = Debug|x86
{58FE24D7-ED03-46B5-8F3E-3E52AF821089}.Debug|x86.Build.0 = Debug|x86
{58FE24D7-ED03-46B5-8F3E-3E52AF821089}.Release|x86.ActiveCfg = Release|x86
{58FE24D7-ED03-46B5-8F3E-3E52AF821089}.Release|x86.Build.0 = Release|x86
EndGlobalSection
EndGlobal
<Properties StartupItem="Cmake-Project-Generator/Cmake-Project-Generator.csproj" />
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProjectGuid>{58FE24D7-ED03-46B5-8F3E-3E52AF821089}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>CmakeProjectGenerator</RootNamespace>
<AssemblyName>Cmake-Project-Generator</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>true</Externalconsole>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Externalconsole>true</Externalconsole>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
using System;
using System.IO;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime;
namespace CmakeProjectGenerator
{
class MainClass
{
static string ProjectName;
static string ProjectBasePath;
static List<string> CompilerFlags = new List<string>();
static string BinaryOutputDir;
static string CodeDirectory;
static List<string> SubDirectories = new List<string>();
static string ProjectPath;
static List<string> IncludeDirs = new List<string> ();
public static bool CheckForYN()
{
string input = "";
while (input != "Y" || input != "N") {
input = Console.ReadLine ();
if (input == "Y" || input == "N")
break;
else
Console.WriteLine ("Enter [Y] or [N]");
}
if (input == "Y")
return true;
else
return false;
}
public static void Main (string[] args)
{
Console.WriteLine ("Hello welcome to the cmake project generator");
Console.WriteLine ("Specify ProjectName:");
ProjectName = Console.ReadLine ();
Console.WriteLine ("Specify ProjectPath:");
ProjectBasePath = Console.ReadLine ();
Console.WriteLine("Add Debug option? [Y/N]");
if(CheckForYN())
{
CompilerFlags.Add ("-g");
}
Console.WriteLine("Add C++11 option? [Y/N]");
if(CheckForYN())
{
CompilerFlags.Add ("-std=c++11");
}
Console.WriteLine("Add -Wall option? [Y/N]");
if(CheckForYN())
{
CompilerFlags.Add ("-Wall");
}
//Console.WriteLine ("Which one is the code directory (relative path)");
//CodeDirectory = Console.ReadLine ();
string subDir = "";
Console.WriteLine ("Add any sub directories? [Y/N]");
if(Console.ReadLine() == "Y")
{
Console.WriteLine ("Specify all subdirectories, relative to the src dir, Enter [N] if you had enough");
while (subDir != "N") {
//Console.WriteLine ("Specify all subdirectories, relative to the src dir, Enter [N] if you had enough");
subDir = Console.ReadLine ();
if (subDir == "N" || subDir == "n")
break;
SubDirectories.Add (subDir);
}
Console.WriteLine ("This tool will automatically create the subdirectories and create a CmakeLists.txt file in them");
}
Console.WriteLine ("Create project ? [Y/N]");
if(Console.ReadLine() == "Y")
{
ProjectPath = Path.Combine (ProjectBasePath, ProjectName);
Directory.CreateDirectory(ProjectPath);
Directory.CreateDirectory (Path.Combine (ProjectPath, "src"));
Directory.CreateDirectory (Path.Combine (ProjectPath, "bin"));
Directory.CreateDirectory (Path.Combine (ProjectPath, "build"));
Directory.CreateDirectory (Path.Combine (ProjectPath, "lib"));
Directory.CreateDirectory (Path.Combine (ProjectPath, "doc"));
Directory.CreateDirectory (Path.Combine (ProjectPath, "scripts"));
Console.WriteLine ("Created Directories");
StreamWriter cmakeWriter = new StreamWriter (Path.Combine (ProjectPath, "CMakeLists.txt"));
cmakeWriter.WriteLine ("cmake_minimum_required(VERSION 2.8)");
cmakeWriter.WriteLine ();
cmakeWriter.WriteLine ("set (PROJECT_NAME_STR " + ProjectName+")");
cmakeWriter.WriteLine ("project(${PROJECTNAME_STR} C CXX)");
cmakeWriter.WriteLine ();
cmakeWriter.WriteLine ("set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin CACHE PATH \"Output directory for libraries\")");
cmakeWriter.WriteLine ("set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin CACHE PATH \"Output directory for executables\")");
cmakeWriter.WriteLine ();
string definitions = "";
foreach (var item in CompilerFlags) {
definitions += " " + item;
}
cmakeWriter.WriteLine("add_definitions("+ definitions + ")");
cmakeWriter.WriteLine ();
CodeDirectory = Path.Combine (ProjectPath, "src");
cmakeWriter.WriteLine ("add_subdirectory(${PROJECT_SOURCE_DIR}/src/)");
cmakeWriter.WriteLine ();
IncludeDirs.Add ("${PROJECT_SOURCE_DIR}/src");
foreach (var item in SubDirectories) {
IncludeDirs.Add ("${PROJECT_SOURCE_DIR}/src/" + item);
}
string include = "";
foreach (var item in IncludeDirs) {
include += " " + item;
}
cmakeWriter.WriteLine ("include_directories(" + include + ")");
cmakeWriter.WriteLine ();
cmakeWriter.WriteLine ();
cmakeWriter.WriteLine ("add_executable(${PROJECT_NAME_STR}_exec ${PROJECT_SOURCE_DIR}/src/main.cpp)");
cmakeWriter.WriteLine ();
cmakeWriter.WriteLine ("target_link_libraries(${PROJECT_NAME_STR}_exec root_lib");
foreach (var item in SubDirectories) {
cmakeWriter.WriteLine (item);
}
cmakeWriter.WriteLine (")");
cmakeWriter.Close();
StreamWriter mainWriter = new StreamWriter (Path.Combine (CodeDirectory, "main.cpp"));
mainWriter.WriteLine ("#include<iostream>");
mainWriter.WriteLine ("int main(void)");
mainWriter.WriteLine ("{");
mainWriter.WriteLine ("std::cout << \"hello\";");
mainWriter.WriteLine ("}");
mainWriter.Close ();
StreamWriter exampleWriter = new StreamWriter (Path.Combine (CodeDirectory, "example.cpp"));
exampleWriter.WriteLine ("//This is an example file so that the compilation of the empty project will succeed, you can remove it");
exampleWriter.WriteLine ("#include<iostream>");
exampleWriter.WriteLine ("int test(void)");
exampleWriter.WriteLine ("{");
exampleWriter.WriteLine ("std::cout << \"hello\";");
exampleWriter.WriteLine ("}");
exampleWriter.Close ();
StreamWriter cmakeSrcWriter = new StreamWriter (Path.Combine (CodeDirectory, "CMakeLists.txt"));
cmakeSrcWriter.WriteLine("include_directories(${CMAKE_CURRENT_SOURCE_DIR})");
foreach (var item in SubDirectories) {
Directory.CreateDirectory(Path.Combine(CodeDirectory, item));
cmakeSrcWriter.WriteLine("add_subdirectory(${PROJECT_SOURCE_DIR}/src/"+item+")");
}
cmakeSrcWriter.WriteLine ("file(GLOB SRC_FILES ./*.c*)");
cmakeSrcWriter.WriteLine("list(REMOVE_ITEM SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp)");
cmakeSrcWriter.WriteLine("MESSAGE(${SRC_FILES})");
cmakeSrcWriter.WriteLine ("add_library(root_lib");
cmakeSrcWriter.WriteLine ("${SRC_FILES}");
cmakeSrcWriter.WriteLine (")");
cmakeSrcWriter.Close ();
foreach (var item in SubDirectories) {
StreamWriter subDirWriter = new StreamWriter (Path.Combine (CodeDirectory, Path.Combine (item, "CMakeLists.txt")));
subDirWriter.WriteLine("include_directories(${CMAKE_CURRENT_SOURCE_DIR})");
subDirWriter.WriteLine ("file(GLOB SRC_FILES ./*.c*)");
subDirWriter.WriteLine ("add_library(" + item);
subDirWriter.WriteLine ("${SRC_FILES}");
subDirWriter.WriteLine (")");
subDirWriter.Close ();
}
foreach (var item in SubDirectories) {
StreamWriter subDirCodeWriter = new StreamWriter (Path.Combine (CodeDirectory, Path.Combine (item, item+".cpp")));
subDirCodeWriter.WriteLine ("//This is an example file so that the compilation of the empty project will succeed, you can remove it");
subDirCodeWriter.WriteLine ("#include<iostream>");
subDirCodeWriter.WriteLine ("int test(void)");
subDirCodeWriter.WriteLine ("{");
subDirCodeWriter.WriteLine ("std::cout << \"hello\";");
subDirCodeWriter.WriteLine ("}");
subDirCodeWriter.Close ();
}
Console.WriteLine ("Now open a console an do:");
Console.WriteLine ("cd " + ProjectPath + "/build");
Console.WriteLine ("cmake ..");
Console.WriteLine ("make");
Console.WriteLine ("Do you want me to run this ? [Y/N]");
if(CheckForYN())
{
Process cmakeP = new Process ();
cmakeP.StartInfo = new ProcessStartInfo ("cmake"){ WorkingDirectory = Path.Combine (ProjectPath, "build") , Arguments = ".."};
cmakeP.Start ();
cmakeP.WaitForExit ();
Process makeP = new Process ();
makeP.StartInfo = new ProcessStartInfo ("make"){ WorkingDirectory = Path.Combine (ProjectPath, "build") };
makeP.Start ();
makeP.WaitForExit ();
}
}
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle ("Cmake-Project-Generator")]
[assembly: AssemblyDescription ("")]
[assembly: AssemblyConfiguration ("")]
[assembly: AssemblyCompany ("")]
[assembly: AssemblyProduct ("")]
[assembly: AssemblyCopyright ("firesurfer")]
[assembly: AssemblyTrademark ("")]
[assembly: AssemblyCulture ("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion ("1.0.*")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]
cmake_minimum_required(VERSION 2.8)
set PROJECT_NAME_STR testAbc
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin CACHE PATH "Output directory for libraries")
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin CACHE PATH "Output directory for executables")
add_definitions( -g -std=c++11 -Wall)
#Get all files in src dir
file(GLOB SRC_FILES {CMAKE_CURRENT_SOURCE_DIR}/src/*.c*)
list(REMOVE_ITEM SRC_FILES main.cpp)
add_library(root_lib
${SRC_FILES}
)
add_executable(${PROJECT_NAME_STR}_exec ${PROJECT_SOURCE_DIR}/src/main.cpp)
target_link_libraries(${PROJECT_NAME_STR}_exec root_lib
)
#include<iostream>
int main(void)
{
std::cout << "hello"
}
// <autogenerated />
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.5", FrameworkDisplayName = "")]
/home/firesurfer/Cmake-Project-Generator/Cmake-Project-Generator/obj/x86/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs
/home/firesurfer/Cmake-Project-Generator/Cmake-Project-Generator/bin/Debug/Cmake-Project-Generator.exe.mdb
/home/firesurfer/Cmake-Project-Generator/Cmake-Project-Generator/bin/Debug/Cmake-Project-Generator.exe
/home/firesurfer/Cmake-Project-Generator/Cmake-Project-Generator/obj/x86/Debug/Cmake-Project-Generator.exe
/home/firesurfer/Cmake-Project-Generator/Cmake-Project-Generator/obj/x86/Debug/Cmake-Project-Generator.exe.mdb
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment