From 93b226c64241b7a38f93226ab1fc628bdfed746b Mon Sep 17 00:00:00 2001 From: "U-olece-PC\\olece" Date: Wed, 17 Feb 2016 09:49:04 +0100 Subject: [PATCH] Got rid of absolute build path variables in MSYS2. juCi++ can now safely be installed through a MSYS2 package --- docs/install.md | 2 +- src/CMakeLists.txt | 4 ---- src/config.cc | 8 ++++++++ src/config.h | 4 ++++ src/files.h | 2 +- src/source_clang.cc | 5 +---- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/docs/install.md b/docs/install.md index cf0744b..256527b 100644 --- a/docs/install.md +++ b/docs/install.md @@ -86,7 +86,7 @@ make install ``` ##Windows with MSYS2 (https://msys2.github.io/) -**MSYS2 does not yet support lldb, but you can still compile juCi++ without debug support. Also for the time being, MSYS2 must be installed in the default MSYS2 folder (C:\msys64 or C:\msys32).** +**MSYS2 does not yet support lldb, but you can still compile juCi++ without debug support.** Note that juCi++ must be run in a MinGW Shell (for instance MinGW-w64 Win64 Shell). diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6ec044c..9307767 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,10 +21,6 @@ if(UNIX) #Checking if compiling on Ubuntu that has a buggy menu system endif() endif() -if(MSYS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMSYS_PROCESS_USE_SH -DJUCI_CMAKE_INSTALL_PREFIX=\\\"${CMAKE_INSTALL_PREFIX}\\\"") -endif() - INCLUDE(FindPkgConfig) find_package(LibClang REQUIRED) diff --git a/src/config.cc b/src/config.cc index 23ab06b..212ec56 100644 --- a/src/config.cc +++ b/src/config.cc @@ -5,6 +5,7 @@ #include #include "filesystem.h" #include "terminal.h" +#include Config::Config() { std::vector environment_variables = {"JUCI_HOME", "HOME", "AppData"}; @@ -25,6 +26,13 @@ Config::Config() { searched_envs+="]"; throw std::runtime_error("One of these environment variables needs to point to a writable directory to save configuration: " + searched_envs); } + +#ifdef _WIN32 + terminal.msys2_mingw_path=boost::filesystem::path(std::getenv("WD")).parent_path().parent_path().parent_path(); + std::string msystem=std::getenv("MSYSTEM"); + std::transform(msystem.begin(), msystem.end(), msystem.begin(), ::tolower); + terminal.msys2_mingw_path/=msystem; +#endif } void Config::load() { diff --git a/src/config.h b/src/config.h index e7ce328..1add042 100644 --- a/src/config.h +++ b/src/config.h @@ -26,6 +26,10 @@ public: public: std::string clang_format_command; int history_size; + +#ifdef _WIN32 + boost::filesystem::path msys2_mingw_path; +#endif }; class Project { diff --git a/src/files.h b/src/files.h index 75941a1..1a7debb 100644 --- a/src/files.h +++ b/src/files.h @@ -125,7 +125,7 @@ const std::string configjson = " \"debug_build_path_comment\": \"Use to insert the project top level directory name, and to insert your default_build_path setting.\",\n" " \"debug_build_path\": \"/debug\",\n" #ifdef _WIN32 -" \"cmake_command\": \"cmake -G\\\"MSYS Makefiles\\\" -DCMAKE_INSTALL_PREFIX="+JUCI_CMAKE_INSTALL_PREFIX+"\",\n" +" \"cmake_command\": \"cmake -G\\\"MSYS Makefiles\\\"\",\n" #else " \"cmake_command\": \"cmake\",\n" #endif diff --git a/src/source_clang.cc b/src/source_clang.cc index 3007ef1..a8397b6 100644 --- a/src/source_clang.cc +++ b/src/source_clang.cc @@ -200,10 +200,7 @@ std::vector Source::ClangViewParse::get_compilation_commands() { arguments.emplace_back("-I/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1"); //Added for OS X 10.11 #endif #ifdef _WIN32 - arguments.emplace_back("-IC:/msys32/mingw32/lib/clang/"+clang_version+"/include"); - arguments.emplace_back("-IC:/msys32/mingw64/lib/clang/"+clang_version+"/include"); - arguments.emplace_back("-IC:/msys64/mingw32/lib/clang/"+clang_version+"/include"); - arguments.emplace_back("-IC:/msys64/mingw64/lib/clang/"+clang_version+"/include"); + arguments.emplace_back("-I"+(Config::get().terminal.msys2_mingw_path/"lib/clang"/clang_version/"include").string()); #endif } arguments.emplace_back("-fretain-comments-from-system-headers");