diff --git a/docs/building.md b/docs/building.md
index 2715d79a5..0a70fb206 100644
--- a/docs/building.md
+++ b/docs/building.md
@@ -93,7 +93,7 @@ interchangeable right now.
* Normal building via `xb build` uses Make.
* [CodeLite](https://codelite.org) is supported. `xb devenv` will generate a workspace and attempt to open it. Your distribution's version may be out of date so check their website.
-* Experimental CMake generation is available to facilitate use of other IDEs such as [CLion](https://www.jetbrains.com/clion/). `build/CMakeLists.txt` is generated by invoking `xb premake --devenv=cmake`.
+* Experimental CMake generation is available to facilitate use of other IDEs such as [CLion](https://www.jetbrains.com/clion/). If `clion` is available inside `$PATH`, `xb devenv` will start it. Otherwise `build/CMakeLists.txt` needs to be generated by invoking `xb premake --devenv=cmake` manually.
Clang-9 or newer should be available from system repositories on all up to date distributions.
You will also need some development libraries. To get them on an Ubuntu system:
diff --git a/xenia-build b/xenia-build
index 3b27e656f..89a14c651 100755
--- a/xenia-build
+++ b/xenia-build
@@ -88,6 +88,16 @@ def main():
sys.exit(return_code)
+def print_box(msg):
+ """Prints an important message inside a box
+ """
+ print(
+ '┌{0:─^{2}}╖\n'
+ '│{1: ^{2}}║\n'
+ '╘{0:═^{2}}╝\n'
+ .format('', msg, len(msg) + 2))
+
+
def import_vs_environment():
"""Finds the installed Visual Studio version and imports
interesting environment variables into os.environ.
@@ -153,6 +163,7 @@ def import_subprocess_environment(args):
os.environ[var.upper()] = setting
break
+
def has_bin(binary):
"""Checks whether the given binary is present.
@@ -408,6 +419,43 @@ def get_build_bin_path(args):
return os.path.join(self_path, 'build', 'bin', platform.capitalize(), args['config'].capitalize())
+def create_clion_workspace():
+ """Creates some basic workspace information inside the .idea directory for first start.
+ """
+ if os.path.exists('.idea'):
+ # No first start
+ return False
+ print('Generating CLion workspace files...')
+ # Might become easier in the future: https://youtrack.jetbrains.com/issue/CPP-7911
+
+ # Set the location of the CMakeLists.txt
+ os.mkdir('.idea')
+ with open(os.path.join('.idea', 'misc.xml'), 'w') as f:
+ f.write("""
+
+
+
+
+
+""")
+
+ # Set available configurations
+ # TODO Find a way to trigger a cmake reload
+ with open(os.path.join('.idea', 'workspace.xml'), 'w') as f:
+ f.write("""
+
+
+
+
+
+
+
+
+""")
+
+ return True
+
+
def discover_commands(subparsers):
"""Looks for all commands and returns a dictionary of them.
In the future commands could be discovered on disk.
@@ -1446,8 +1494,13 @@ class DevenvCommand(Command):
def execute(self, args, pass_args, cwd):
devenv = None
+ show_reload_prompt = False
if sys.platform == 'win32':
print('Launching Visual Studio...')
+ elif has_bin('clion') or has_bin('clion.sh'):
+ print('Launching CLion...')
+ show_reload_prompt = create_clion_workspace()
+ devenv = 'cmake'
else:
print('Launching CodeLite...')
devenv = 'codelite'
@@ -1458,11 +1511,23 @@ class DevenvCommand(Command):
print('')
print('- launching devenv...')
+ if show_reload_prompt:
+ print_box('Please run "File ⇒ ↺ Reload CMake Project" from inside the IDE!')
if sys.platform == 'win32':
shell_call([
'devenv',
'build\\xenia.sln',
])
+ elif has_bin('clion'):
+ shell_call([
+ 'clion',
+ '.',
+ ])
+ elif has_bin('clion.sh'):
+ shell_call([
+ 'clion.sh',
+ '.',
+ ])
else:
shell_call([
'codelite',