ENH: Grouping the logic that detects getopt.c into a single .cmake file.
authorLuis Ibanez <luis.ibanez@gmail.com>
Sun, 5 Sep 2010 20:15:05 +0000 (20:15 +0000)
committerLuis Ibanez <luis.ibanez@gmail.com>
Sun, 5 Sep 2010 20:15:05 +0000 (20:15 +0000)
Multiple directories were repeating this configuration independently.
The directory jp3d is expected to be self-suficient so it still does
the configuration directly.

CMake/CheckHaveGetopt.cmake [new file with mode: 0644]
CMakeLists.txt
JavaOpenJPEG/CMakeLists.txt
codec/CMakeLists.txt
jpwl/CMakeLists.txt

diff --git a/CMake/CheckHaveGetopt.cmake b/CMake/CheckHaveGetopt.cmake
new file mode 100644 (file)
index 0000000..c0fd5dc
--- /dev/null
@@ -0,0 +1,15 @@
+# Check if getopt is present:
+INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
+SET(DONT_HAVE_GETOPT 1)
+IF(UNIX) #I am pretty sure only *nix sys have this anyway
+  CHECK_INCLUDE_FILE("getopt.h" CMAKE_HAVE_GETOPT_H)
+  # Seems like we need the contrary:
+  IF(CMAKE_HAVE_GETOPT_H)
+    SET(DONT_HAVE_GETOPT 0)
+  ENDIF(CMAKE_HAVE_GETOPT_H)
+ENDIF(UNIX)
+
+IF(DONT_HAVE_GETOPT)
+  ADD_DEFINITIONS(-DDONT_HAVE_GETOPT)
+ENDIF(DONT_HAVE_GETOPT)
+
index ee7305a529f1c3f1ffd8af2dac6f6ba9c9aa23ac..14ec7ea232827895edb542c6fd944954e55f73be 100644 (file)
@@ -107,6 +107,10 @@ ENDIF(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
 # Test for some required system information.
 INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityC.cmake)
 
+#-----------------------------------------------------------------------------
+# Test for getopt being available in this system
+INCLUDE (${PROJECT_SOURCE_DIR}/CMake/CheckHaveGetopt.cmake )
+
 #-----------------------------------------------------------------------------
 # Setup file for setting custom ctest vars
 CONFIGURE_FILE(
index 2405846381091b88080bd4869c23ab4179c49fe0..c115e4aa5ce9a5af7cca64ce9074f7c3458b8d92 100644 (file)
@@ -4,20 +4,9 @@
 SET(common_SRCS
   convert.c
   )
-# Then check if getopt is present:
-INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
-SET(DONT_HAVE_GETOPT 1)
-IF(UNIX) #I am pretty sure only *nix sys have this anyway
-  CHECK_INCLUDE_FILE("getopt.h" CMAKE_HAVE_GETOPT_H)
-  # Seems like we need the contrary:
-  IF(CMAKE_HAVE_GETOPT_H)
-    SET(DONT_HAVE_GETOPT 0)
-  ENDIF(CMAKE_HAVE_GETOPT_H)
-ENDIF(UNIX)
 
 # If not getopt was found then add it to the lib:
 IF(DONT_HAVE_GETOPT)
-  ADD_DEFINITIONS(-DDONT_HAVE_GETOPT)
   SET(common_SRCS
     ${common_SRCS}
     compat/getopt.c
index 2c0d6184e70996e167a5c7c989d584655638e5ba..da2cb630cf52cb44d53a33d2b3c626bf80bb96f4 100644 (file)
@@ -6,20 +6,8 @@ SET(common_SRCS
   index.c
 )
 
-# Then check if getopt is present:
-INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
-SET(DONT_HAVE_GETOPT 1)
-IF(UNIX) #I am pretty sure only *nix sys have this anyway
-  CHECK_INCLUDE_FILE("getopt.h" CMAKE_HAVE_GETOPT_H)
-  # Seems like we need the contrary:
-  IF(CMAKE_HAVE_GETOPT_H)
-    SET(DONT_HAVE_GETOPT 0)
-  ENDIF(CMAKE_HAVE_GETOPT_H)
-ENDIF(UNIX)
-
 # If not getopt was found then add it to the lib:
 IF(DONT_HAVE_GETOPT)
-  ADD_DEFINITIONS(-DDONT_HAVE_GETOPT)
   SET(common_SRCS
     ${common_SRCS}
     compat/getopt.c
index a24210f0449affb85f74ddd323e7cdc72cb0a14c..7063229bf1091ed6befd5fc9d9a7d6335cdb7d59 100755 (executable)
@@ -24,20 +24,8 @@ SET(OPJ_SRCS
 )
 SET(JPWL_SRCS crc.c jpwl.c jpwl_lib.c rs.c)
 
-# Then check if getopt is present:
-INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
-SET(DONT_HAVE_GETOPT 1)
-IF(UNIX) #I am pretty sure only *nix sys have this anyway
-  CHECK_INCLUDE_FILE("getopt.h" CMAKE_HAVE_GETOPT_H)
-  # Seems like we need the contrary:
-  IF(CMAKE_HAVE_GETOPT_H)
-    SET(DONT_HAVE_GETOPT 0)
-  ENDIF(CMAKE_HAVE_GETOPT_H)
-ENDIF(UNIX)
-
 # If not getopt was found then add it to the lib:
 IF(DONT_HAVE_GETOPT)
-  ADD_DEFINITIONS(-DDONT_HAVE_GETOPT)
   SET(OPJ_SRCS
     ${OPJ_SRCS}
     ../codec/compat/getopt.c