CMakeLists.txt
changeset 1038 16b7dedb02a5
parent 1037 d452f4da0970
child 1039 6ea910694da8
--- a/CMakeLists.txt	Mon Feb 01 23:15:36 2010 -0500
+++ b/CMakeLists.txt	Tue Feb 02 22:49:48 2010 -0500
@@ -379,25 +379,34 @@
         ENDIF((NOT CMAKE_BUILD_TYPE STREQUAL "") AND (NOT CMAKE_BUILD_TYPE STREQUAL "Debug"))
     ENDIF(DEFINED CMAKE_BUILD_TYPE)
 
+    SET(SWIG_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/physfs-swig-bindings")
+
     MACRO(CONFIGURE_SWIG_BINDING _LANG _INSTALLPATH _EXTRAOUTPUTS _EXTRACFLAGS _EXTRALDFLAGS)
         STRING(TOUPPER "${_LANG}" _UPPERLANG)
         STRING(TOLOWER "${_LANG}" _LOWERLANG)
         SET(_TARGET "physfs-${_LOWERLANG}")
+        SET(_TARGETDIR "${SWIG_OUTPUT_DIR}/${_LOWERLANG}")
+
+        IF(NOT EXISTS "${_TARGETDIR}")
+            FILE(MAKE_DIRECTORY "${_TARGETDIR}")
+        ENDIF(NOT EXISTS "${_TARGETDIR}")
+
         IF(PHYSFS_BUILD_${_UPPERLANG})
             ADD_CUSTOM_COMMAND(
-                OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/physfs-${_LOWERLANG}.c" ${_EXTRAOUTPUTS}
+                OUTPUT "${_TARGETDIR}/${_TARGET}.c" ${_EXTRAOUTPUTS}
                 MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/extras/physfs-swig.i"
                 COMMAND "${SWIG}"
-                ARGS ${SWIG_OPT_CFLAGS} -${_LOWERLANG} -outdir "${CMAKE_CURRENT_BINARY_DIR}" -o "${CMAKE_CURRENT_BINARY_DIR}/physfs-${_LOWERLANG}.c" "${CMAKE_CURRENT_SOURCE_DIR}/extras/physfs-swig.i"
+                ARGS ${SWIG_OPT_CFLAGS} -${_LOWERLANG} -outdir "${_TARGETDIR}" -o "${_TARGETDIR}/${_TARGET}.c" "${CMAKE_CURRENT_SOURCE_DIR}/extras/physfs-swig.i"
                 COMMENT "Generating ${_LANG} bindings..."
             )
 
-            ADD_LIBRARY(${_TARGET} SHARED "${CMAKE_CURRENT_BINARY_DIR}/physfs-${_LOWERLANG}.c")
+            ADD_LIBRARY(${_TARGET} SHARED "${_TARGETDIR}/${_TARGET}.c")
             TARGET_LINK_LIBRARIES(${_TARGET} ${PHYSFS_LIB_TARGET})
             SET_TARGET_PROPERTIES(${_TARGET} PROPERTIES
                 COMPILE_FLAGS "${_EXTRACFLAGS}"
                 LINK_FLAGS "${_EXTRALDFLAGS}"
-                OUTPUT_NAME "physfs"
+                LIBRARY_OUTPUT_NAME "physfs"
+                LIBRARY_OUTPUT_DIRECTORY "${_TARGETDIR}"
             )
             INSTALL(TARGETS ${_TARGET} LIBRARY DESTINATION "${_INSTALLPATH}")
             MESSAGE(STATUS "${_LANG} bindings configured!")
@@ -469,8 +478,8 @@
         SET(PERL_LIBPERL "-l${PERL_LIBPERL}")
     ENDIF(MACOSX)
 
-    CONFIGURE_SWIG_BINDING(Perl "${PERL_INSTALL_PATH}" "${CMAKE_CURRENT_BINARY_DIR}/physfs.pm" "\"-I${PERL_INCLUDE_PATH}/CORE\" ${PERL_CCFLAGS} -w" "\"-L${PERL_INCLUDE_PATH}/CORE\" ${PERL_LIBPERL} ${PERL_LDFLAGS}")
-    INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/physfs.pm" DESTINATION "${PERL_INSTALL_PATH}")
+    CONFIGURE_SWIG_BINDING(Perl "${PERL_INSTALL_PATH}" "${SWIG_OUTPUT_DIR}/perl/physfs.pm" "\"-I${PERL_INCLUDE_PATH}/CORE\" ${PERL_CCFLAGS} -w" "\"-L${PERL_INCLUDE_PATH}/CORE\" ${PERL_LIBPERL} ${PERL_LDFLAGS}")
+    INSTALL(FILES "${SWIG_OUTPUT_DIR}/perl/physfs.pm" DESTINATION "${PERL_INSTALL_PATH}")
 ENDIF(PHYSFS_BUILD_PERL)
 
 IF(PHYSFS_BUILD_RUBY)