Browse Source

Revise AutoInclude.cmake: My version of CMake, despite being >=2.8.11, doesn't actually support CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE.

Sam Edwards 12 years ago
parent
commit
4fa6584fdf
1 changed files with 14 additions and 8 deletions
  1. 14 8
      cmake/modules/AutoInclude.cmake

+ 14 - 8
cmake/modules/AutoInclude.cmake

@@ -4,8 +4,12 @@
 #   behavior by default.
 #   behavior by default.
 #
 #
 
 
-# Emulate CMake 2.8.11's CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE behavior.
-if(CMAKE_VERSION VERSION_LESS 2.8.11)
+# Emulate CMake 2.8.11's CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE behavior if
+# this version doesn't define CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE.
+# CFSworks's version of CMake (2.8.12) doesn't have
+# CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE even though it should be supported,
+# hence test if it's defined (as either ON or OFF) before trying to use it.
+if("${CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE}" STREQUAL "")
   # Replace some built-in functions in order to extend their functionality.
   # Replace some built-in functions in order to extend their functionality.
   function(add_library target)
   function(add_library target)
     _add_library(${target} ${ARGN})
     _add_library(${target} ${ARGN})
@@ -29,14 +33,16 @@ if(CMAKE_VERSION VERSION_LESS 2.8.11)
       endif()
       endif()
     endforeach()
     endforeach()
 
 
-    list(REMOVE_DUPLICATES interface_dirs)
+    if(interface_dirs)
+      list(REMOVE_DUPLICATES interface_dirs)
 
 
-    #NB. target_include_directories is new in 2.8.8.
-    #target_include_directories("${target}" ${interface_dirs})
-    include_directories(${interface_dirs})
+      #NB. target_include_directories is new in 2.8.8.
+      #target_include_directories("${target}" ${interface_dirs})
+      include_directories(${interface_dirs})
 
 
-    # Update this target's interface inc dirs.
-    set_target_properties("${target}" PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${target_interface_dirs};${interface_dirs}")
+      # Update this target's interface inc dirs.
+      set_target_properties("${target}" PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${target_interface_dirs};${interface_dirs}")
+    endif()
 
 
     # Call to the built-in function we are overriding.
     # Call to the built-in function we are overriding.
     _target_link_libraries(${target} ${ARGN})
     _target_link_libraries(${target} ${ARGN})