Skip to content

Commit

Permalink
Initial CMake build scripts
Browse files Browse the repository at this point in the history
Builds successfully on macOS 10.13, untested but should work on Linux and possibly even even Windows (issues charlesangus#1 and charlesangus#2)
  • Loading branch information
dbr committed Jan 7, 2019
1 parent 6b90c40 commit fd7421d
Show file tree
Hide file tree
Showing 4 changed files with 223 additions and 1 deletion.
99 changes: 99 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
cmake_minimum_required(VERSION 3.4)

# Pick up share/cmake/ modules
# TODO: Append instead of overriding
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/share/cmake)

# If CMAKE_INSTALL_EXEC_PREFIX is not specified, install binaries
# directly into the regular install prefix
if(NOT CMAKE_INSTALL_EXEC_PREFIX)
message("Exec prefix not specified, defaulting to ${CMAKE_INSTALL_PREFIX}")
set(CMAKE_INSTALL_EXEC_PREFIX ${CMAKE_INSTALL_PREFIX})
endif()

# Locate Nuke or error
find_package(Nuke REQUIRED)
message("Build Nuke plugins against ${Nuke_LIBRARY_DIR}")

if(Nuke_DDImageVersion VERSION_LESS 11)
# No C++11 stuff until compiler update in Nuke 11
else()
set (CMAKE_CXX_STANDARD 11)
endif()

if(APPLE)
# Flag required on OS X to allow Nuke API symbols to be found at runtime
set(DEEPC_LINK_FLAGS "-undefined dynamic_lookup")
else()
set(DEEPC_LINK_FLAGS "")
endif()


# Include Nuke headers
include_directories(
${Nuke_INCLUDE_DIR}
)

# Add plugins
add_library(DeepCAddChannels SHARED
src/DeepCAddChannels.cpp
)
add_library(DeepCBlink SHARED
src/DeepCBlink.cpp
)
add_library(DeepCGrade SHARED
src/DeepCGrade.cpp
)
add_library(DeepCID SHARED
src/DeepCID.cpp
)
add_library(DeepCPMatte SHARED
src/DeepCPMatte.cpp
)
#add_library(DeepCPNoise SHARED
# src/DeepCPNoise.cpp
#)
add_library(DeepCRemoveChannels SHARED
src/DeepCRemoveChannels.cpp
)
add_library(DeepCSaturation SHARED
src/DeepCSaturation.cpp
)
add_library(DeepCShuffle SHARED
src/DeepCShuffle.cpp
)
add_library(DeepCWorld SHARED
src/DeepCWorld.cpp
)


set_target_properties(
DeepCAddChannels
DeepCBlink
DeepCGrade
DeepCID
DeepCPMatte
#DeepCPNoise
DeepCRemoveChannels
DeepCSaturation
DeepCShuffle
DeepCWorld

PROPERTIES
PREFIX "" # No lib prefix
LINK_FLAGS "${DEEPC_LINK_FLAGS}"
)

# Once built, copy the library into install location (e.g "executable-prefix/lib/nuke/6.2")
install(TARGETS
DeepCAddChannels
DeepCBlink
DeepCGrade
DeepCID
DeepCPMatte
#DeepCPNoise
DeepCRemoveChannels
DeepCSaturation
DeepCShuffle
DeepCWorld
DESTINATION ${CMAKE_INSTALL_EXEC_PREFIX}/plugins)
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,18 @@ Possible someday...

### Mac

Unlikely...
For Nuke 11, you must have Xcode 8.2 installed with clang (you may be able to use a slightly different version) - see [here for details from Foundry](https://learn.foundry.com/nuke/developers/113/ndkdevguide/appendixa/osx.html). Installing the smaller "Xcode Command Line" also appears to work well, using the command `xcode-select --install`

For older versions of Nuke (10.5 and earlier) the plugins must be built with GCC, not Clang. [This page](https://learn.foundry.com/nuke/developers/105/ndkdevguide/appendixa/osx.html) recommends you use GCC 4.0, but GCC 4.2 appears to work perfectly. However acquiring either of these ancient versions can be a challenge (building the compiler from source is slow but may be the easiest way)

With the appropriate compiler installed, to build:

mkdir build
cd build
cmake -D CMAKE_INSTALL_PREFIX=inst -D NUKE_INSTALL_PATH=/Applications/Nuke11.3v1/Nuke11.3v1.app/Contents/MacOS/ ..
make install

The path must be changed to the installed version of Nuke. It should be the folder *which contains* the `include/` folder.

## Contributing

Expand Down
97 changes: 97 additions & 0 deletions share/cmake/FindNuke.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#==========
#
# Copyright (c) 2010, Dan Bethell.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# * Neither the name of Dan Bethell nor the names of any
# other contributors to this software may be used to endorse or
# promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#==========
#
# Variables defined by this module:
# Nuke_FOUND
# Nuke_INCLUDE_DIR
# Nuke_COMPILE_FLAGS
# Nuke_LINK_FLAGS
# Nuke_LIBRARIES
# Nuke_LIBRARY_DIR
#
# Usage:
# FIND_PACKAGE( Nuke )
# FIND_PACKAGE( Nuke REQUIRED )
#
# Note:
# You can tell the module where Nuke is installed by setting
# the NUKE_INSTALL_PATH (or setting the NDK_PATH environment
# variable before calling FIND_PACKAGE.
#
# E.g.
# SET( NUKE_INSTALL_PATH "/usr/local/Nuke5.2v3" )
# FIND_PACKAGE( Nuke REQUIRED )
#
#==========

# our includes
FIND_PATH( Nuke_INCLUDE_DIR DDImage/Op.h
$ENV{NDK_PATH}/include
${NUKE_INSTALL_PATH}/include
)

# our library
FIND_LIBRARY( Nuke_LIBRARIES DDImage
$ENV{NDK_PATH}
${NUKE_INSTALL_PATH}
)

SET( Nuke_COMPILE_FLAGS "" )
SET( Nuke_LINK_FLAGS "" )
IF( ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
SET( Nuke_COMPILE_FLAGS "-arch i386" )
SET( Nuke_LINK_FLAGS "-arch i386" )
ENDIF( ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )

# our library path
GET_FILENAME_COMPONENT( Nuke_LIBRARY_DIR ${Nuke_LIBRARIES} PATH )

# did we find everything?
INCLUDE( FindPackageHandleStandardArgs )
FIND_PACKAGE_HANDLE_STANDARD_ARGS( "Nuke" DEFAULT_MSG
Nuke_INCLUDE_DIR
Nuke_LIBRARIES
Nuke_LIBRARY_DIR
)

SET( Nuke_DDImageVersion "" )
IF( NUKE_FOUND )
TRY_RUN(NUKE_VERSION_EXITCODE NUKE_VERSION_COMPILED
${CMAKE_BINARY_DIR} ${CMAKE_MODULE_PATH}/TestForDDImageVersion.cxx
COMPILE_DEFINITIONS "-I${Nuke_INCLUDE_DIR}"
RUN_OUTPUT_VARIABLE Nuke_DDImageVersion)
message(STATUS "Nuke_DDImageVersion: --${Nuke_DDImageVersion}--")
ENDIF()

15 changes: 15 additions & 0 deletions share/cmake/TestForDDImageVersion.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <iostream>
#include "DDImage/ddImageVersionNumbers.h"
int main(int, char*[])
{
// Print a Nuke API identifier number, used to make the
// lib/nuke${API_NUMBER} directory

// Nuke aims to maintain API compatibilty between "v" releases, so
// compiling for 6.1v1 will work with 6.1v2 etc (but not
// 6.2v1). Only exception has been 5.1v5 and 5.1v6 (because it was
// supposed to be 5.2v1)
std::cout << kDDImageVersionMajorNum << "." << kDDImageVersionMinorNum;
return 0;
}

0 comments on commit fd7421d

Please sign in to comment.