From 584409b2efe3e4fc28f179aa87ba73d56f19e5a0 Mon Sep 17 00:00:00 2001
From: Seth Hillbrand <hillbrand@ucdavis.edu>
Date: Tue, 15 May 2018 06:40:25 -0700
Subject: [PATCH] Make OpenCascade more secondary

The opencascade patch intrusively checked against libraries but broke
some build scripts.  This restores the default cmake OCE behavior that was
changed by 2bab30d9a and makes the OpenCascade search truly secondary.
---
 CMakeLists.txt                  | 9 +++++++--
 common/CMakeLists.txt           | 2 ++
 plugins/3d/oce/CMakeLists.txt   | 1 +
 utils/kicad2step/CMakeLists.txt | 3 ++-
 4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6aac2cf95e..c9d86b9c23 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -627,11 +627,16 @@ if( KICAD_SPICE )
 endif()
 
 # Find OpenCascade Community Edition, required for STEP plugin and tools
-if( KICAD_USE_OCE OR KICAD_USE_OCC )
+if( KICAD_USE_OCE )
+    set( OCC_LIBRARIES TKBinXCAF TKPCAF TKSTEP TKXDESTEP TKIGES TKXDEIGES )
+
+    find_package( OCE 0.16 REQUIRED ${OCC_LIBRARIES} )
+
+elseif( KICAD_USE_OCC )
     find_package(OpenCASCADE)
     if( NOT OCC_FOUND )
         MESSAGE( FATAL_ERROR "================================================================\n"
-                             "Neither OpenCASCADE Community Edition nor OpenCASCADE was found!\n"
+                             " KICAD_USE_OCC=True but OpenCASCADE was no found!\n"
                              "================================================================\n")
     endif()
     if( OCC_VERSION_STRING VERSION_LESS 6.8.0 )
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
index f1e9a58774..be3f65a9b7 100644
--- a/common/CMakeLists.txt
+++ b/common/CMakeLists.txt
@@ -13,6 +13,8 @@ include_directories(
     ${GLEW_INCLUDE_DIR}
     ${GLM_INCLUDE_DIR}
     ${CURL_INCLUDE_DIRS}
+    ${OCE_INCLUDE_DIRS}
+    ${OCC_INCLUDE_DIR}
     ../3d-viewer
     ../pcbnew
     ../polygon
diff --git a/plugins/3d/oce/CMakeLists.txt b/plugins/3d/oce/CMakeLists.txt
index 1c6df742d4..fe35c81ac9 100644
--- a/plugins/3d/oce/CMakeLists.txt
+++ b/plugins/3d/oce/CMakeLists.txt
@@ -13,6 +13,7 @@
 #
 
 include_directories( SYSTEM
+    ${OCE_INCLUDE_DIRS}
     ${OCC_INCLUDE_DIR}
 )
 
diff --git a/utils/kicad2step/CMakeLists.txt b/utils/kicad2step/CMakeLists.txt
index 53186213ab..728dcbcc56 100644
--- a/utils/kicad2step/CMakeLists.txt
+++ b/utils/kicad2step/CMakeLists.txt
@@ -4,7 +4,8 @@ include_directories( BEFORE
     ${CMAKE_SOURCE_DIR}/include
 )
 
-include_directories( SYSTEM 
+include_directories( SYSTEM
+    ${OCE_INCLUDE_DIRS}
     ${OCC_INCLUDE_DIR}
 )