Skip to content

Commit 24b8b06

Browse files
committed
updated CMmakeLists for building with Supernova
Also updated instructions and regactored CMakeLists so the .cpp file needs to be specified at the beginning of the file, while the project name is inferred from that filename
1 parent 3583c1b commit 24b8b06

File tree

5 files changed

+106
-14
lines changed

5 files changed

+106
-14
lines changed

01a-BoringMixer/CMakeLists.txt

+25-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,34 @@
1+
set(FILENAME "BoringMixer.cpp") #specify the .cpp file here
12
cmake_minimum_required (VERSION 2.8)
2-
set(PROJECT "BoringMixer")
3+
get_filename_component(PROJECT ${FILENAME} NAME_WE) #automatically sets project name from the filename
4+
# set(PROJECT "my_name") #alternatively set project name manually
5+
message(STATUS "Project name is ${PROJECT}")
36
project (${PROJECT})
47

58
include_directories(${SC_PATH}/include/plugin_interface)
69
include_directories(${SC_PATH}/include/common)
710
include_directories(${SC_PATH}/common)
811

9-
1012
set(CMAKE_SHARED_MODULE_PREFIX "")
1113
if(APPLE OR WIN32)
1214
set(CMAKE_SHARED_MODULE_SUFFIX ".scx")
1315
endif()
1416

17+
option(SUPERNOVA "Build plugins for supernova" OFF)
18+
if (SUPERNOVA)
19+
include_directories(${SC_PATH}/external_libraries/nova-tt)
20+
# actually just boost.atomic
21+
include_directories(${SC_PATH}/external_libraries/boost)
22+
include_directories(${SC_PATH}/external_libraries/boost_lockfree)
23+
include_directories(${SC_PATH}/external_libraries/boost-lockfree)
24+
endif()
25+
26+
option(CPP11 "Build with c++11." ON)
27+
28+
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
29+
set(CMAKE_COMPILER_IS_CLANG 1)
30+
endif()
31+
1532
# The below monstrosity sets compiler flags for SSE (Streaming SIMD Extensions). Among many other things, SSE protects
1633
# against denormal numbers, which are known to cause glitchy audio in some cases.
1734

@@ -71,4 +88,9 @@ if(MINGW)
7188
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mstackrealign")
7289
endif()
7390

74-
add_library(${PROJECT} MODULE BoringMixer.cpp)
91+
add_library(${PROJECT} MODULE ${FILENAME})
92+
if(SUPERNOVA)
93+
add_library(${PROJECT}_supernova MODULE ${FILENAME})
94+
set_property(TARGET ${PROJECT}_supernova
95+
PROPERTY COMPILE_DEFINITIONS SUPERNOVA)
96+
endif()

01b-BoringMixer/CMakeLists.txt

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,34 @@
1+
set(FILENAME "BoringMixer.cpp") #specify the .cpp file here
12
cmake_minimum_required (VERSION 2.8)
2-
set(PROJECT "BoringMixer")
3+
get_filename_component(PROJECT ${FILENAME} NAME_WE) #automatically sets project name from the filename
4+
# set(PROJECT "my_name") #alternatively set project name manually
5+
message(STATUS "Project name is ${PROJECT}")
36
project (${PROJECT})
47

58
include_directories(${SC_PATH}/include/plugin_interface)
69
include_directories(${SC_PATH}/include/common)
710
include_directories(${SC_PATH}/common)
811

9-
1012
set(CMAKE_SHARED_MODULE_PREFIX "")
1113
if(APPLE OR WIN32)
1214
set(CMAKE_SHARED_MODULE_SUFFIX ".scx")
1315
endif()
1416

17+
option(SUPERNOVA "Build plugins for supernova" OFF)
18+
if (SUPERNOVA)
19+
include_directories(${SC_PATH}/external_libraries/nova-tt)
20+
# actually just boost.atomic
21+
include_directories(${SC_PATH}/external_libraries/boost)
22+
include_directories(${SC_PATH}/external_libraries/boost_lockfree)
23+
include_directories(${SC_PATH}/external_libraries/boost-lockfree)
24+
endif()
25+
1526
option(CPP11 "Build with c++11." ON)
1627

28+
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
29+
set(CMAKE_COMPILER_IS_CLANG 1)
30+
endif()
31+
1732
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG)
1833
add_definitions(-fvisibility=hidden)
1934

@@ -66,4 +81,9 @@ if(MINGW)
6681
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mstackrealign")
6782
endif()
6883

69-
add_library(${PROJECT} MODULE BoringMixer.cpp)
84+
add_library(${PROJECT} MODULE ${FILENAME})
85+
if(SUPERNOVA)
86+
add_library(${PROJECT}_supernova MODULE ${FILENAME})
87+
set_property(TARGET ${PROJECT}_supernova
88+
PROPERTY COMPILE_DEFINITIONS SUPERNOVA)
89+
endif()

02-MySaw/CMakeLists.txt

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,34 @@
1+
set(FILENAME "MySaw.cpp") #specify the .cpp file here
12
cmake_minimum_required (VERSION 2.8)
2-
set(PROJECT "MySaw")
3+
get_filename_component(PROJECT ${FILENAME} NAME_WE) #automatically sets project name from the filename
4+
# set(PROJECT "my_name") #alternatively set project name manually
5+
message(STATUS "Project name is ${PROJECT}")
36
project (${PROJECT})
47

58
include_directories(${SC_PATH}/include/plugin_interface)
69
include_directories(${SC_PATH}/include/common)
710
include_directories(${SC_PATH}/common)
811

9-
1012
set(CMAKE_SHARED_MODULE_PREFIX "")
1113
if(APPLE OR WIN32)
1214
set(CMAKE_SHARED_MODULE_SUFFIX ".scx")
1315
endif()
1416

17+
option(SUPERNOVA "Build plugins for supernova" OFF)
18+
if (SUPERNOVA)
19+
include_directories(${SC_PATH}/external_libraries/nova-tt)
20+
# actually just boost.atomic
21+
include_directories(${SC_PATH}/external_libraries/boost)
22+
include_directories(${SC_PATH}/external_libraries/boost_lockfree)
23+
include_directories(${SC_PATH}/external_libraries/boost-lockfree)
24+
endif()
25+
1526
option(CPP11 "Build with c++11." ON)
1627

28+
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
29+
set(CMAKE_COMPILER_IS_CLANG 1)
30+
endif()
31+
1732
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG)
1833
add_definitions(-fvisibility=hidden)
1934

@@ -66,4 +81,9 @@ if(MINGW)
6681
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mstackrealign")
6782
endif()
6883

69-
add_library(${PROJECT} MODULE MySaw.cpp)
84+
add_library(${PROJECT} MODULE ${FILENAME})
85+
if(SUPERNOVA)
86+
add_library(${PROJECT}_supernova MODULE ${FILENAME})
87+
set_property(TARGET ${PROJECT}_supernova
88+
PROPERTY COMPILE_DEFINITIONS SUPERNOVA)
89+
endif()

03-AnalogEcho/CMakeLists.txt

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,34 @@
1+
set(FILENAME "AnalogEcho.cpp") #specify the .cpp file here
12
cmake_minimum_required (VERSION 2.8)
2-
set(PROJECT "AnalogEcho")
3+
get_filename_component(PROJECT ${FILENAME} NAME_WE) #automatically sets project name from the filename
4+
# set(PROJECT "my_name") #alternatively set project name manually
5+
message(STATUS "Project name is ${PROJECT}")
36
project (${PROJECT})
47

58
include_directories(${SC_PATH}/include/plugin_interface)
69
include_directories(${SC_PATH}/include/common)
710
include_directories(${SC_PATH}/common)
811

9-
1012
set(CMAKE_SHARED_MODULE_PREFIX "")
1113
if(APPLE OR WIN32)
1214
set(CMAKE_SHARED_MODULE_SUFFIX ".scx")
1315
endif()
1416

17+
option(SUPERNOVA "Build plugins for supernova" OFF)
18+
if (SUPERNOVA)
19+
include_directories(${SC_PATH}/external_libraries/nova-tt)
20+
# actually just boost.atomic
21+
include_directories(${SC_PATH}/external_libraries/boost)
22+
include_directories(${SC_PATH}/external_libraries/boost_lockfree)
23+
include_directories(${SC_PATH}/external_libraries/boost-lockfree)
24+
endif()
25+
1526
option(CPP11 "Build with c++11." ON)
1627

28+
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
29+
set(CMAKE_COMPILER_IS_CLANG 1)
30+
endif()
31+
1732
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG)
1833
add_definitions(-fvisibility=hidden)
1934

@@ -66,4 +81,9 @@ if(MINGW)
6681
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mstackrealign")
6782
endif()
6883

69-
add_library(${PROJECT} MODULE AnalogEcho.cpp)
84+
add_library(${PROJECT} MODULE ${FILENAME})
85+
if(SUPERNOVA)
86+
add_library(${PROJECT}_supernova MODULE ${FILENAME})
87+
set_property(TARGET ${PROJECT}_supernova
88+
PROPERTY COMPILE_DEFINITIONS SUPERNOVA)
89+
endif()

README.md

+12-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Beyond this repository, the reader is encouraged to look at [sc3-plugins](https:
1717

1818
## Compiling
1919

20-
This is how you build one of the examples in this directory. The examples are kept separate with duplicated code so that you can simply copy out a directory to start your own ugen. **Currently, this build system is missing two things: Windows and supernova. Sorry, we're working on it...**
20+
This is how you build one of the examples in this directory. The examples are kept separate with duplicated code so that you can simply copy out a directory to start your own ugen (see [Development workflow](#development-workflow)). **Currently, this build system is missing Windows. Sorry, we're working on it...**
2121

2222
Before you can compile any plugin, you will need a copy of the SuperCollider *source code* (NOT the app itself). The source code version should match your SuperCollider app version. Slight differences will probably be tolerated, but if they're too far apart you will get an "API version mismatch" error when you boot the server.
2323

@@ -39,7 +39,14 @@ Here, `/path/to/sc3source/` is the path to the source code. Once again, this is
3939

4040
The path should contain a file at `include/plugin_interface/SC_PlugIn.h`. If you get a warning that `SC_PlugIn.h` could not be found, then `SC_PATH` is not set correctly. If no `SC_PATH` is provided, the build system assumes the SuperCollider include files in `/usr/include/SuperCollider/`.
4141

42-
CMake will remember your `SC_PATH`, so you only need to run that once. After that, simply build using `make`:
42+
CMake will remember your `SC_PATH`, so you only need to run that once.
43+
44+
If you also want to build a UGen for Supernova, then you need to set the 'SUPERNOVA' flag. The CMake command would then look like this:
45+
46+
```shell
47+
example-plugins/01a-BoringMixer/build/$ cmake -DSC_PATH=/path/to/sc3source/ -DSUPERNOVA=ON ..
48+
```
49+
After that, simply build using `make`:
4350

4451
```shell
4552
example-plugins/01a-BoringMixer/build/$ make
@@ -51,9 +58,12 @@ This will produce a "shared library" file ending in `.scx`. On Linux, the extens
5158

5259
Copy, move, or symbolic link the folder into your Extensions folder. You can find out which one that is by evaluating `Platform.userExtensionDir` in sclang. You can install the plugin(s) system-wide by copying to `Platform.systemExtensionDir`.
5360

61+
Please note that currently (as of January 2018) Supernova is more picky about location of UGens on macOS. They need to be placed in a subdirectory called `plugins` inside the above mentioned extension directory. This pertains only to the UGen file (`.scx`), not the `.sc` class file.
62+
5463
If you're not using sclang, the installation method varies. Ask the developer(s) of the client if you're not sure how.
5564

5665
## Development workflow
66+
In order to start developing a new UGen, make a copy of one of the example's directory. Change the `.cpp` filename, as well as the name and contents of the corresponding `.sc` file, and update the beginning of `CMakeLists.txt` with your new `.cpp` filename. Then you're ready to work on the code.
5767

5868
If you change your source file(s) or `CMakeLists.txt`, simply use `make` to recompile the shared library. You will need to restart scsynth/supernova for your changes to take effect.
5969

0 commit comments

Comments
 (0)