Skip to content
This repository has been archived by the owner on Mar 16, 2021. It is now read-only.

You might want this? I took your fine work and automated the installation. #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
69 changes: 36 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,23 @@ utilize Introjucer without being forced to a particular IDE.
Project setup
-------------

First, generate a new Juce project with Introjucer. Then add this project's
repository to your Juce project as a submodule under the `Builds` folder. So
an example project structure might look something like this:
First, generate a new Juce project with Introjucer.

/path/to/YourProjectName
├── Builds
│   ├── CMakeJuce <-- This repo
│   ├── Linux
│   ├── MacOSX
│   └── VisualStudio2013
├── CMakeLists.txt
├── YourProjectName.jucer
├── JuceLibraryCode
│   ├── AppConfig.h
│   ├── JuceHeader.h
│   ├── ReadMe.txt
│   └── modules
├── LICENSE
├── README.md
├── Source
│   ├── PluginEditor.cpp
│   ├── PluginEditor.h
│   ├── PluginProcessor.cpp
│   └── PluginProcessor.h
Usage
-----
1. Run the python script '''cmakejuce_init''' from your projects root folder.

2. Once you have the initial project set up, point your CMake-supported IDE to
the top-level `CMakeLists.txt` file and everything should work out! This
project will generate for you two targets, `YourProjectName` and
`virtual_TARGET`. Set `YourProjectName` as the compiler target as the
`virtual_TARGET` is only used to give a target to the IDE for correct indexing
of the project's source code.

Create the following `CMakeLists.txt` file in your project's top-level
directory:
What the script does
--------------------
The python script creates the following `CMakeLists.txt` file in your
project's top-level directory:

```cmake
cmake_minimum_required(VERSION 2.8)
Expand Down Expand Up @@ -72,16 +61,30 @@ the same directory as the Introjucer-generated build file. That way, compiler
errors will have correct relative paths and be rendered as links in IDEs that
support this feature.

The project structure will look something like this:

/path/to/YourProjectName
├── Builds
│   ├── CMakeJuce <-- This repo
│   ├── Linux
│   ├── MacOSX
│   └── VisualStudio2013
├── CMakeLists.txt
├── YourProjectName.jucer
├── JuceLibraryCode
│   ├── AppConfig.h
│   ├── JuceHeader.h
│   ├── ReadMe.txt
│   └── modules
├── LICENSE
├── README.md
├── Source
│   ├── PluginEditor.cpp
│   ├── PluginEditor.h
│   ├── PluginProcessor.cpp
│   └── PluginProcessor.h

Usage
-----

Once you have the initial project set up, point your CMake-supported IDE to
the top-level `CMakeLists.txt` file and everything should work out! This
project will generate for you two targets, `YourProjectName` and
`virtual_TARGET`. Set `YourProjectName` as the compiler target as the
`virtual_TARGET` is only used to give a target to the IDE for correct indexing
of the project's source code.


[juce]: http://www.juce.com
Expand Down
105 changes: 104 additions & 1 deletion juce.cmake → cmakejuce_init
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
#!/usr/bin/python
#
#
from __future__ import print_function
import sys
import os

g_cmakejuce_folder = 'Builds/CMakeJuce'

def usage():
print ('usage:')
print ('from your root project folder:')
print (' create_cmake_juce [<project_name>]')
print ('if no project name is specified then if a single .jucer file')
print ('is present in the current folder then the name of the jucer')
print ('file will be used.')
sys.exit(1)

def create_cmake_folder():
try:
os.mkdir(g_cmakejuce_folder)
except:
print ('Could not create folder. Perhaps builds folder not found.')
print ('Are we in a jucer project folder structure?')
usage()

f = open(g_cmakejuce_folder + '/juce.cmake', 'w')

print ("""
cmake_minimum_required(VERSION 2.8)

# TODO: Document and split off to submodule
Expand Down Expand Up @@ -54,6 +83,8 @@ file(GLOB_RECURSE juce_SOURCES
"${juce_SOURCE_DIR}/*.mm"
)

set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

# Help some IDEs with #include completion
include_directories(${juce_SOURCE_DIR})

Expand Down Expand Up @@ -86,4 +117,76 @@ set_target_properties(virtual_TARGET
"${plugin_OUTPUT}")

# Allow the main target to build with the external build target
add_dependencies(virtual_TARGET ${main_TARGET})
add_dependencies(virtual_TARGET ${main_TARGET})
""", file=f)
f.close()
return

def get_name_of_single_jucer():
result = None
files_in_current_dir = os.listdir('.')
for f in files_in_current_dir:
if f.endswith('.jucer'):
if result is None:
result = f
else:
print ('multiple jucer files found')
usage()

return result


def get_project_name():
if len(sys.argv) > 1:
possible_name = sys.argv[1]
else:
possible_name = get_name_of_single_jucer()

if possible_name is None:
print ('error: no project name found')
usage()

return possible_name



def create_root_file(project_name):
f = open('CMakeLists.txt', 'w')
print ('cmake_minimum_required(VERSION 2.8)', file=f)
print ('project(' + project_name + ')', file=f)

print ('if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")', file=f)
print (' add_subdirectory(Builds/MacOSX)', file=f)
print ('elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")', file=f)
print (' add_subdirectory(Builds/Linux)', file=f)
print ('endif()', file=f)
f.close()
pass


def create_per_project_file(build_folder_name):
original_folder = os.getcwd()

try:
os.chdir('Builds/MacOSX')
except OSError:
print ("failed to find", build_folder_name, "build folder")
os.chdir(original_folder)
return

f = open('CMakeLists.txt', 'w')
print ('cmake_minimum_required(VERSION 2.8)', file=f)
print ('include (../CMakeJuce/juce.cmake)', file=f)
f.close()
return


# main...
proj_name = get_project_name()
print ("creating for project", proj_name)

create_root_file(proj_name)
create_cmake_folder()
create_per_project_file('MacOSX')
create_per_project_file('Linux')