Switch default compiler to clang with ninja

master
Joey Pollack 2 years ago
parent 407d30f853
commit 55db1098b8

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.16.3) cmake_minimum_required(VERSION 3.16.3)
# Set the project name and version # Set the project name and version
project(cgen VERSION 1.0.5) project(cgen VERSION 1.1.0)
# specify the C++ standard # specify the C++ standard
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)

@ -45,6 +45,7 @@ int main(int argc, char** argv)
argParser.AddArg(ArgDesc("-x", true, 1, "Add executable submodule projects, separated by ',' (ex: -x first,second,third)")); argParser.AddArg(ArgDesc("-x", true, 1, "Add executable submodule projects, separated by ',' (ex: -x first,second,third)"));
argParser.AddArg(ArgDesc("-r", true, 0, "Remove the root project executable")); argParser.AddArg(ArgDesc("-r", true, 0, "Remove the root project executable"));
argParser.AddArg(ArgDesc("-gs", true, 0, "Add git subsystem updating to the main cmake file.")); argParser.AddArg(ArgDesc("-gs", true, 0, "Add git subsystem updating to the main cmake file."));
argParser.AddArg(ArgDesc("-b", true, 1, "Set the default compiler on windows (msvc, clang). Default is msvc"));
bool result = argParser.Parse(); bool result = argParser.Parse();
@ -496,7 +497,15 @@ int main(int argc, char** argv)
ofs << "\n echo Build mode is Debug"; ofs << "\n echo Build mode is Debug";
ofs << "\n)"; ofs << "\n)";
ofs << "\necho using options %options%"; ofs << "\necho using options %options%";
if (argParser.ContainsOption("-b") && jpUtils::StringManip::ToLower(argParser.GetOptionValue("-b").values[0]) == "msvc")
{
ofs << "\ncmake -Wno-dev %build_type% %options% -B build/ -S . -G " << vs_version.c_str() << " -A x64"; ofs << "\ncmake -Wno-dev %build_type% %options% -B build/ -S . -G " << vs_version.c_str() << " -A x64";
}
else
{
ofs << "\ncmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -Wno-dev -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang %build_type% %options% -B build/ -S . -G Ninja";
}
ofs << "\ngoto exit"; ofs << "\ngoto exit";
ofs << "\n"; ofs << "\n";
@ -554,7 +563,15 @@ int main(int argc, char** argv)
ofs << "\n)"; ofs << "\n)";
if (argParser.ContainsOption("-b") && jpUtils::StringManip::ToLower(argParser.GetOptionValue("-b").values[0]) == "msvc")
{
ofs << "\ncmake --build build/ --target ALL_BUILD"; ofs << "\ncmake --build build/ --target ALL_BUILD";
}
else
{
ofs << "\ncmake --build build/ --target all";
}
ofs << "\n\nSET BUILD_ERRORLEVEL=!ERRORLEVEL!"; ofs << "\n\nSET BUILD_ERRORLEVEL=!ERRORLEVEL!";
ofs << "\nIF NOT \"!BUILD_ERRORLEVEL!\"==\"0\" ("; ofs << "\nIF NOT \"!BUILD_ERRORLEVEL!\"==\"0\" (";
ofs << "\n\techo %ESC%[91mBUILD FAILED!%ESC%[0m %BUILD_ERRORLEVEL%"; ofs << "\n\techo %ESC%[91mBUILD FAILED!%ESC%[0m %BUILD_ERRORLEVEL%";

Loading…
Cancel
Save