Blob Blame History Raw
From 09f27c7d680c6904b8cd83acd5b7b0c7267a0035 Mon Sep 17 00:00:00 2001
From: Frederik Aalund <frederikaalund@gmail.com>
Date: Thu, 13 Dec 2012 14:16:42 +0100
Subject: [PATCH 1/5] Fixed compilation of static build on Windows 7 using
 Visual Studio 2010

---
 CMakeLists.txt                       |   12 +++++---
 export/OpenColorIO/OpenColorABI.h.in |   50 ++++++++++++++++++++--------------
 share/cmake/FindYAML_CPP.cmake       |   27 ++++++++++++++++++
 src/core/CMakeLists.txt              |   11 ++++----
 4 files changed, 71 insertions(+), 29 deletions(-)
 create mode 100644 share/cmake/FindYAML_CPP.cmake

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3e36ca5..bdefe33 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -156,13 +156,13 @@ if(USE_EXTERNAL_TINYXML)
         if(TINYXML_VERSION VERSION_EQUAL ${TINYXML_VERSION_MIN} OR
            TINYXML_VERSION VERSION_GREATER ${TINYXML_VERSION_MIN})
             message(STATUS "External TinyXML will be used.")
+            include_directories(BEFORE ${TINYXML_INCLUDE_DIRS})
         else()
             message(FATAL_ERROR "ERROR: ${TINYXML_VERSION} found, but ${TINYXML_VERSION_MIN} or newer is required.")
         endif()
     else(TINYXML_FOUND)
         message(STATUS "TinyXML was not found. Perhaps you forgot to install the development package?")
     endif(TINYXML_FOUND)
-
 else(USE_EXTERNAL_TINYXML)
     set(TINYXML_VERSION 2_6_1)
     set(TINYXML_CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR}/ext/dist)
@@ -189,8 +189,12 @@ endif(USE_EXTERNAL_TINYXML)
 if(USE_EXTERNAL_YAML)
     # Set minimum yaml version for non-patched sources.
     set(YAML_VERSION_MIN "0.3.0")
-    include(FindPkgConfig)
-    pkg_check_modules(YAML_CPP yaml-cpp)
+    include(FindPkgConfig) 
+    if(PKG_CONFIG_EXECUTABLE)
+        pkg_check_modules(YAML_CPP yaml-cpp)
+    else(PKG_CONFIG_EXECUTABLE)
+        find_package(YAML_CPP)
+    endif(PKG_CONFIG_EXECUTABLE)
     if(YAML_CPP_FOUND)
         if(YAML_CPP_VERSION VERSION_EQUAL ${YAML_VERSION_MIN} OR
            YAML_CPP_VERSION VERSION_GREATER ${YAML_VERSION_MIN})
@@ -403,4 +407,4 @@ add_custom_target(test_verbose
                   COMMENT "Running ctest with verbose output")
 
 # Log CMake first run done
-SET(CMAKE_FIRST_RUN 0 CACHE INTERNAL "")
+SET(CMAKE_FIRST_RUN 0 CACHE INTERNAL "")
\ No newline at end of file
diff --git a/export/OpenColorIO/OpenColorABI.h.in b/export/OpenColorIO/OpenColorABI.h.in
index d39d586..2c06568 100644
--- a/export/OpenColorIO/OpenColorABI.h.in
+++ b/export/OpenColorIO/OpenColorABI.h.in
@@ -59,31 +59,41 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <tr1/memory>
 #define OCIO_SHARED_PTR std::tr1::shared_ptr
 #define OCIO_DYNAMIC_POINTER_CAST std::tr1::dynamic_pointer_cast
+#elif _MSC_VER >= 1600
+#include <memory>
+#define OCIO_SHARED_PTR std::shared_ptr
+#define OCIO_DYNAMIC_POINTER_CAST std::dynamic_pointer_cast
 #else
-#error OCIO needs gcc 4 or later to get access to <tr1/memory> (or specify USE_BOOST_PTR instead)
+#error OCIO needs at least gcc 4 or vc 2010 to get access to <tr1/memory> or <memory>, respectively (or specify USE_BOOST_PTR instead)
 #endif
 
+
 // If supported, define OCIOEXPORT, OCIOHIDDEN
 // (used to choose which symbols to export from OpenColorIO)
-#if defined __linux__ || __APPLE__
-    #if __GNUC__ >= 4
-        #define OCIOEXPORT __attribute__ ((visibility("default")))
-        #define OCIOHIDDEN __attribute__ ((visibility("hidden")))
-    #else
-        #define OCIOEXPORT
-        #define OCIOHIDDEN
-    #endif
-#elif defined(_WIN32) || defined(_WIN64) || defined(_WINDOWS) || defined(_MSC_VER)
-    // Windows requires you to export from the main library and then import in any others
-    #if defined OpenColorIO_EXPORTS
-        #define OCIOEXPORT __declspec(dllexport)
-    #else
-        #define OCIOEXPORT __declspec(dllimport)
-    #endif
-    #define OCIOHIDDEN
-#else // Others platforms not supported atm
-    #define OCIOEXPORT
-    #define OCIOHIDDEN
+#ifndef OCIO_BUILD_STATIC
+	#if defined __linux__ || __APPLE__
+		#if __GNUC__ >= 4
+			#define OCIOEXPORT __attribute__ ((visibility("default")))
+			#define OCIOHIDDEN __attribute__ ((visibility("hidden")))
+		#else
+			#define OCIOEXPORT
+			#define OCIOHIDDEN
+		#endif
+	#elif defined(_WIN32) || defined(_WIN64) || defined(_WINDOWS) || defined(_MSC_VER)
+		// Windows requires you to export from the main library and then import in any others
+		#if defined OpenColorIO_EXPORTS
+			#define OCIOEXPORT __declspec(dllexport)
+		#else
+			#define OCIOEXPORT __declspec(dllimport)
+		#endif
+		#define OCIOHIDDEN
+	#else // Others platforms not supported atm
+		#define OCIOEXPORT
+		#define OCIOHIDDEN
+	#endif
+#else
+	#define OCIOEXPORT
+	#define OCIOHIDDEN
 #endif
 
 #endif // INCLUDED_OCIO_OPENCOLORABI_H
diff --git a/share/cmake/FindYAML_CPP.cmake b/share/cmake/FindYAML_CPP.cmake
new file mode 100644
index 0000000..318dca3
--- /dev/null
+++ b/share/cmake/FindYAML_CPP.cmake
@@ -0,0 +1,27 @@
+# Find the YAML-CPP library.
+#
+# Sets the usual variables expected for find_package scripts:
+#
+#  YAML_CPP_INCLUDE_DIRS - header location
+#  YAML_CPP_LIBRARIES - library to link against
+#  YAML_CPP_FOUND - true if YAML_CPP was found.
+
+find_path(YAML_CPP_INCLUDE_DIR yaml-cpp/yaml.h)
+find_library(YAML_CPP_LIBRARY NAMES yaml-cpp)
+
+# Support the REQUIRED and QUIET arguments, and set YAML_CPP_FOUND if found.
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(
+    YAML_CPP
+    DEFAULT_MSG
+    YAML_CPP_LIBRARY YAML_CPP_INCLUDE_DIR)
+
+#  TODO: Infer the version string from the YAMLCPP installation instead.
+set(YAML_CPP_VERSION "0.0.0" CACHE STRING "The version of the YAMLCPP Library")
+
+if(YAML_CPP_FOUND)
+    set(YAML_CPP_LIBRARIES ${YAML_CPP_LIBRARY})
+    set(YAML_CPP_INCLUDE_DIRS ${YAML_CPP_INCLUDE_DIR})
+endif()
+
+mark_as_advanced(YAML_CPP_LIBRARY YAML_CPP_INCLUDE_DIR)
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 50194f3..fbc3bcd 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -60,11 +60,12 @@ if(OCIO_BUILD_STATIC)
     list(REMOVE_ITEM core_src_files ${CMAKE_SOURCE_DIR}/src/core/UnitTest.cpp)
     add_library(OpenColorIO_STATIC STATIC ${core_src_files})
     add_dependencies(OpenColorIO_STATIC tinyxml YAML_CPP_LOCAL)
+    add_definitions(-DOCIO_BUILD_STATIC)
     if(WIN32)
-        target_link_libraries(OpenColorIO_STATIC
-            debug ${EXTERNAL_DEBUG_LIBRARIES}
-            optimized ${EXTERNAL_OPTIMIZED_LIBRARIES}
-            general ${EXTERNAL_GENERAL_LIBRARIES})
+    #    target_link_libraries(OpenColorIO_STATIC
+    #        debug ${EXTERNAL_DEBUG_LIBRARIES}
+    #        optimized ${EXTERNAL_OPTIMIZED_LIBRARIES}
+    #        general ${EXTERNAL_GENERAL_LIBRARIES})
     else()
         target_link_libraries(OpenColorIO_STATIC ${EXTERNAL_GENERAL_LIBRARIES})
     endif()
@@ -90,4 +91,4 @@ message(STATUS "Create OpenColorIO.pc from OpenColorIO.pc.in")
 configure_file(${CMAKE_SOURCE_DIR}/export/pkgconfig/OpenColorIO.pc.in
     ${CMAKE_CURRENT_BINARY_DIR}/OpenColorIO.pc @ONLY)
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/OpenColorIO.pc
-    DESTINATION ${CMAKE_INSTALL_EXEC_PREFIX}/lib${LIB_SUFFIX}/pkgconfig/)
+    DESTINATION ${CMAKE_INSTALL_EXEC_PREFIX}/lib${LIB_SUFFIX}/pkgconfig/)
\ No newline at end of file
-- 
1.7.10


From 436f67eb835d532cfacadb1d7736ea067b4d71c0 Mon Sep 17 00:00:00 2001
From: Frederik Aalund <frederikaalund@gmail.com>
Date: Thu, 13 Dec 2012 14:29:15 +0100
Subject: [PATCH 2/5] Made USE_EXTERNAL_* options available through the CMake
 GUI on Windows systems

---
 CMakeLists.txt |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index bdefe33..63e62fc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -34,7 +34,7 @@ option(OCIO_PYGLUE_RESPECT_ABI "If ON, the Python module install path includes P
 option(OCIO_PYGLUE_SONAME "If ON, soname/soversion will be set for Python module library" OFF)
 option(OCIO_PYGLUE_LIB_PREFIX "If ON, prefix the Python module with 'lib'" OFF)
 
-if(UNIX AND NOT APPLE)
+if((UNIX AND NOT APPLE) OR WIN32)
     option(USE_EXTERNAL_YAML "Use system installed yaml-cpp library." OFF)
     option(USE_EXTERNAL_TINYXML "Use system installed tinyxml library." OFF)
     option(USE_EXTERNAL_LCMS "Use system install lcms2 library." OFF)
-- 
1.7.10


From 43a74507f90142f13be1c2dec4a27448fab056d9 Mon Sep 17 00:00:00 2001
From: Frederik Aalund <frederikaalund@gmail.com>
Date: Tue, 18 Dec 2012 12:10:29 +0100
Subject: [PATCH 3/5] Some fixes for clang and libc++. It now builds the tests
 too.

---
 CMakeLists.txt                         |    9 ++++
 export/OpenColorIO/OpenColorABI.h.in   |    4 ++
 src/aftereffects/OpenColorIO_AE.cpp    |    2 +-
 src/aftereffects/OpenColorIO_AE_UI.cpp |    3 +-
 src/apps/ociobakelut/main.cpp          |   20 +++----
 src/apps/ocioconvert/main.cpp          |   90 ++++++++++++++++++++++++++++++++
 src/core/PathUtils.cpp                 |    6 ++-
 7 files changed, 121 insertions(+), 13 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 63e62fc..0260dfb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -163,6 +163,8 @@ if(USE_EXTERNAL_TINYXML)
     else(TINYXML_FOUND)
         message(STATUS "TinyXML was not found. Perhaps you forgot to install the development package?")
     endif(TINYXML_FOUND)
+
+    set(TINYXML_STATIC_LIBRARIES ${TINYXML_LIBRARIES})
 else(USE_EXTERNAL_TINYXML)
     set(TINYXML_VERSION 2_6_1)
     set(TINYXML_CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR}/ext/dist)
@@ -206,6 +208,13 @@ if(USE_EXTERNAL_YAML)
     else(YAML_CPP_FOUND)
         message(FATAL_ERROR "ERROR: System yaml-cpp library was not found. Make sure the library is installed and the pkg-config file exists.")
     endif(YAML_CPP_FOUND)
+
+    if(WIN32)
+        set(YAML_CPP_STATIC_DEBUG_LIBRARIES ${YAML_CPP_LIBRARIES})
+        set(YAML_CPP_STATIC_OPTIMIZED_LIBRARIES ${YAML_CPP_LIBRARIES})
+    else()
+        set(YAML_CPP_STATIC_GENERAL_LIBRARIES ${YAML_CPP_LIBRARIES})
+    endif()
 else(USE_EXTERNAL_YAML)
     set(YAML_CPP_VERSION 0.3.0)
     set(YAML_CPP_CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR}/ext/dist -DYAML_CPP_BUILD_TOOLS:BOOL=FALSE)
diff --git a/export/OpenColorIO/OpenColorABI.h.in b/export/OpenColorIO/OpenColorABI.h.in
index 2c06568..4915c77 100644
--- a/export/OpenColorIO/OpenColorABI.h.in
+++ b/export/OpenColorIO/OpenColorABI.h.in
@@ -55,6 +55,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <boost/shared_ptr.hpp>
 #define OCIO_SHARED_PTR boost::shared_ptr
 #define OCIO_DYNAMIC_POINTER_CAST boost::dynamic_pointer_cast
+#elif __clang__
+#include <memory>
+#define OCIO_SHARED_PTR std::shared_ptr
+#define OCIO_DYNAMIC_POINTER_CAST std::dynamic_pointer_cast
 #elif __GNUC__ >= 4
 #include <tr1/memory>
 #define OCIO_SHARED_PTR std::tr1::shared_ptr
diff --git a/src/aftereffects/OpenColorIO_AE.cpp b/src/aftereffects/OpenColorIO_AE.cpp
index cd89091..1651e29 100755
--- a/src/aftereffects/OpenColorIO_AE.cpp
+++ b/src/aftereffects/OpenColorIO_AE.cpp
@@ -94,7 +94,7 @@ static PF_Err GlobalSetup(
             pfS->ClearSupportedPixelFormats(in_data->effect_ref);
             
             pfS->AddSupportedPixelFormat(in_data->effect_ref,
-                                            PrPixelFormat_BGRA_4444_32f_Linear);
+                                            PrPixelFormat_BGRA_4444_32f);
             
             in_data->pica_basicP->ReleaseSuite(kPFPixelFormatSuite,
                                                 kPFPixelFormatSuiteVersion1);
diff --git a/src/aftereffects/OpenColorIO_AE_UI.cpp b/src/aftereffects/OpenColorIO_AE_UI.cpp
index b5634bf..c4a19b4 100644
--- a/src/aftereffects/OpenColorIO_AE_UI.cpp
+++ b/src/aftereffects/OpenColorIO_AE_UI.cpp
@@ -594,7 +594,8 @@ static void DoClickPath(
         const char *extension = OCIO::FileTransform::getFormatExtensionByIndex(i);
         const char *format = OCIO::FileTransform::getFormatNameByIndex(i);
     
-        extensions[ extension ] = format;
+        if(extension != std::string("ccc")) // .ccc files require an ID parameter
+            extensions[ extension ] = format;
     }
     
     extensions[ "ocio" ] = "OCIO Format";
diff --git a/src/apps/ociobakelut/main.cpp b/src/apps/ociobakelut/main.cpp
index 265d464..b99d4a4 100644
--- a/src/apps/ociobakelut/main.cpp
+++ b/src/apps/ociobakelut/main.cpp
@@ -73,7 +73,7 @@ int main (int argc, const char* argv[])
     int whitepointtemp = 6505;
     std::string displayicc;
     std::string description;
-    std::string copyright = "OpenColorIO (Sony Imageworks)";
+    std::string copyright = "No copyright. Use freely.";
     
     // What are the allowed baker output formats?
     std::ostringstream formats;
@@ -126,8 +126,8 @@ int main (int argc, const char* argv[])
                //"--cubesize %d", &cubesize, "size of the icc CLUT cube (default: 32)",
                "--whitepoint %d", &whitepointtemp, "whitepoint for the profile (default: 6505)",
                "--displayicc %s", &displayicc , "an icc profile which matches the OCIO profiles target display",
-               "--description %s", &description , "a meaningful description, this will show up in UI like photoshop",
-               "--copyright %s", &copyright , "a copyright field\n",
+               "--description %s", &description , "a meaningful description, this will show up in UI like photoshop (defaults to \"filename.icc\")",
+               "--copyright %s", &copyright , "a copyright field (default: \"No copyright. Use freely.\"\n",
                // TODO: add --metadata option
                NULL);
     
@@ -291,6 +291,13 @@ int main (int argc, const char* argv[])
     {
         if(format == "icc")
         {
+            if(description.empty())
+            {
+                description = outputfile;
+                if(verbose)
+                    std::cout << "[OpenColorIO INFO]: \"--description\" set to default value of filename.icc: " << outputfile << "" << std::endl;
+            }
+            
             if(usestdout)
             {
                 std::cerr << "\nERROR: --stdout not supported when writing icc profiles.\n\n";
@@ -305,13 +312,6 @@ int main (int argc, const char* argv[])
                 return 1;
             }
             
-            if(copyright.empty())
-            {
-                std::cerr << "ERROR: need to specify a --copyright to embed in the icc profile\n";
-                std::cerr << "See --help for more info." << std::endl;
-                return 1;
-            }
-            
             if(cubesize<2) cubesize = 32; // default
 
             OCIO::ConstProcessorRcPtr processor;
diff --git a/src/apps/ocioconvert/main.cpp b/src/apps/ocioconvert/main.cpp
index 32a3c34..60e7f03 100644
--- a/src/apps/ocioconvert/main.cpp
+++ b/src/apps/ocioconvert/main.cpp
@@ -68,6 +68,8 @@ bool ParseNameValuePair(std::string& name, std::string& value,
 
 bool StringToInt(int * ival, const char * str);
 
+bool StringToVector(std::vector<int> * ivector, const char * str);
+
 int main(int argc, const char **argv)
 {
     ArgParse ap;
@@ -75,6 +77,8 @@ int main(int argc, const char **argv)
     std::vector<std::string> floatAttrs;
     std::vector<std::string> intAttrs;
     std::vector<std::string> stringAttrs;
+    std::string keepChannels;
+    bool croptofull = false;
      
     ap.options("ocioconvert -- apply colorspace transform to an image \n\n"
                "usage: ocioconvert [options]  inputimage inputcolorspace outputimage outputcolorspace\n\n",
@@ -83,6 +87,8 @@ int main(int argc, const char **argv)
                "--float-attribute %L", &floatAttrs, "name=float pair defining OIIO float attribute",
                "--int-attribute %L", &intAttrs, "name=int pair defining OIIO int attribute",
                "--string-attribute %L", &stringAttrs, "name=string pair defining OIIO string attribute",
+               "--croptofull", &croptofull, "name=Crop or pad to make pixel data region match the \"full\" region",
+               "--ch %s", &keepChannels, "name=Select channels (e.g., \"2,3,4\")",
                NULL
                );
     if (ap.parse (argc, argv) < 0) {
@@ -138,6 +144,75 @@ int main(int argc, const char **argv)
         
         f->read_image(OIIO::TypeDesc::TypeFloat, &img[0]);
         delete f;
+        
+        std::vector<int> kchannels;
+        //parse --ch argument
+        if (!StringToVector(&kchannels,keepChannels.c_str()))
+        {
+            std::cerr << "Error: --ch: '" << keepChannels << "' should be comma-seperated integers\n";
+            exit(1);
+        }
+        
+        //if kchannels not specified, then keep all channels
+        if (kchannels.size() == 0)
+        {
+            kchannels.resize(components);
+            for (int channel=0; channel < components; channel++)
+            {
+                kchannels[channel] = channel;
+            }
+        }
+        
+        if (croptofull)
+        {
+            imgwidth = spec.full_width;
+            imgheight = spec.full_height;
+            std::cerr << "cropping to " << imgwidth;
+            std::cerr << "x" << imgheight << std::endl;
+        }
+        
+        if (croptofull || (int)kchannels.size() < spec.nchannels)
+        {
+            // crop down bounding box and ditch all but n channels
+            // img is a flattened 3 dimensional matrix heightxwidthxchannels
+            // fill croppedimg with only the needed pixels
+            std::vector<float> croppedimg;
+            croppedimg.resize(imgwidth*imgheight*kchannels.size());
+            for (int y=0 ; y < spec.height ; y++)
+            {
+                for (int x=0 ; x < spec.width; x++)
+                {
+                    for (int k=0; k < (int)kchannels.size(); k++)
+                    {
+                        int channel = kchannels[k];
+                        int current_pixel_y = y + spec.y;
+                        int current_pixel_x = x + spec.x;
+                        
+                        if (current_pixel_y >= 0 &&
+                            current_pixel_x >= 0 &&
+                            current_pixel_y < imgheight &&
+                            current_pixel_x < imgwidth)
+                        {
+                            // get the value at the desired pixel
+                            float current_pixel = img[(y*spec.width*components)
+                                                      + (x*components)+channel];
+                            // put in croppedimg.
+                            croppedimg[(current_pixel_y*imgwidth*kchannels.size())
+                                       + (current_pixel_x*kchannels.size())
+                                       + channel] = current_pixel;
+                        }
+                    }
+                }
+            }
+            // redefine the spec so it matches the new bounding box
+            spec.x = 0;
+            spec.y = 0;
+            spec.height = imgheight;
+            spec.width = imgwidth;
+            spec.nchannels = (int)(kchannels.size());
+            components = (int)(kchannels.size());
+            img = croppedimg;
+        }
     
     }
     catch(...)
@@ -304,6 +379,21 @@ bool StringToInt(int * ival, const char * str)
     return true;
 }
 
+bool StringToVector(std::vector<int> * ivector, const char * str)
+{
+    std::stringstream ss(str);
+    int i;
+    while (ss >> i)
+    {
+        ivector->push_back(i);
+        if (ss.peek() == ',')
+        {
+          ss.ignore();
+        }
+    }
+    return ivector->size() != 0;
+}
+
 
 
 
diff --git a/src/core/PathUtils.cpp b/src/core/PathUtils.cpp
index a04ecee..4c944b1 100644
--- a/src/core/PathUtils.cpp
+++ b/src/core/PathUtils.cpp
@@ -49,10 +49,14 @@
 #if defined(__APPLE__) && !defined(__IPHONE__)
 #include <crt_externs.h> // _NSGetEnviron()
 #elif !defined(WINDOWS)
-#include <unistd.h>
 extern char **environ;
 #endif
 
+#include <unistd.h>
+#if defined(__clang__)
+#include <unistd.h>
+#endif
+
 OCIO_NAMESPACE_ENTER
 {
     namespace
-- 
1.7.10


From 36040a625fc75144663e6c4643d6936bb5174747 Mon Sep 17 00:00:00 2001
From: Frederik Aalund <frederikaalund@gmail.com>
Date: Sun, 23 Dec 2012 13:37:21 +0100
Subject: [PATCH 4/5] Fixed OSX (non-clang) and Linux builds.

	- Fixed when the OCIO_BUILD_STATIC flag gets defined so that OCIO also builds on OSX with a non-clang compiler.
	- I accidentally included <unistd.h> for all builds in PathUtils.cpp because of copy-paste errors. This should now be fixed.
---
 src/core/CMakeLists.txt |   12 ++----------
 src/core/PathUtils.cpp  |    2 +-
 2 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index fbc3bcd..e21197b 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -60,18 +60,10 @@ if(OCIO_BUILD_STATIC)
     list(REMOVE_ITEM core_src_files ${CMAKE_SOURCE_DIR}/src/core/UnitTest.cpp)
     add_library(OpenColorIO_STATIC STATIC ${core_src_files})
     add_dependencies(OpenColorIO_STATIC tinyxml YAML_CPP_LOCAL)
-    add_definitions(-DOCIO_BUILD_STATIC)
-    if(WIN32)
-    #    target_link_libraries(OpenColorIO_STATIC
-    #        debug ${EXTERNAL_DEBUG_LIBRARIES}
-    #        optimized ${EXTERNAL_OPTIMIZED_LIBRARIES}
-    #        general ${EXTERNAL_GENERAL_LIBRARIES})
-    else()
-        target_link_libraries(OpenColorIO_STATIC ${EXTERNAL_GENERAL_LIBRARIES})
-    endif()
+
     set_target_properties(OpenColorIO_STATIC PROPERTIES
         OUTPUT_NAME OpenColorIO
-        COMPILE_FLAGS "${EXTERNAL_COMPILE_FLAGS}"
+        COMPILE_FLAGS "${EXTERNAL_COMPILE_FLAGS}" -DOCIO_BUILD_STATIC
         LINK_FLAGS "${EXTERNAL_LINK_FLAGS}")
     
     message(STATUS "Setting OCIO SOVERSION to: ${SOVERSION}")
diff --git a/src/core/PathUtils.cpp b/src/core/PathUtils.cpp
index 4c944b1..9a3c860 100644
--- a/src/core/PathUtils.cpp
+++ b/src/core/PathUtils.cpp
@@ -49,10 +49,10 @@
 #if defined(__APPLE__) && !defined(__IPHONE__)
 #include <crt_externs.h> // _NSGetEnviron()
 #elif !defined(WINDOWS)
+#include <unistd.h>
 extern char **environ;
 #endif
 
-#include <unistd.h>
 #if defined(__clang__)
 #include <unistd.h>
 #endif
-- 
1.7.10


From c460fce56a0a3b0499d5ff4f39d967688a467d0c Mon Sep 17 00:00:00 2001
From: Frederik Aalund <frederikaalund@gmail.com>
Date: Tue, 25 Dec 2012 21:44:37 +0100
Subject: [PATCH 5/5] Forgot to move the " symbol when adding the
 -DOCIO_BUILD_STATIC line to the compile flags

---
 src/core/CMakeLists.txt |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index e21197b..a355bc5 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -63,7 +63,7 @@ if(OCIO_BUILD_STATIC)
 
     set_target_properties(OpenColorIO_STATIC PROPERTIES
         OUTPUT_NAME OpenColorIO
-        COMPILE_FLAGS "${EXTERNAL_COMPILE_FLAGS}" -DOCIO_BUILD_STATIC
+        COMPILE_FLAGS "${EXTERNAL_COMPILE_FLAGS} -DOCIO_BUILD_STATIC"
         LINK_FLAGS "${EXTERNAL_LINK_FLAGS}")
     
     message(STATUS "Setting OCIO SOVERSION to: ${SOVERSION}")
-- 
1.7.10