cmake:
authorCampbell Barton <ideasman42@gmail.com>
Sun, 19 Jun 2011 06:57:56 +0000 (06:57 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 19 Jun 2011 06:57:56 +0000 (06:57 +0000)
 new macro file_list_suffix() for adding a suffix to every file in a path before the file extension.
 useful to create names for debug libs on windows.

CMakeLists.txt
build_files/cmake/Modules/FindPythonLibsUnix.cmake
build_files/cmake/macros.cmake
source/blender/modifiers/intern/MOD_explode.c

index c4863ea..fed1785 100644 (file)
@@ -247,8 +247,7 @@ set(CXX_WARNINGS "")
 #   cmake ../blender \
 #         -D PYTHON_VERSION=3.2 \
 #         -D PYTHON_INCLUDE_DIRS=/opt/py32/include/python3.2d \
-#         -D PYTHON_LIBPATH=/opt/py32/lib \
-#         -D PYTHON_LIBRARY=python3.2d
+#         -D PYTHON_LIBRARIES=/opt/py32/lib/libpython3.2d.so
 #
 # On Macs: 
 #   cmake ../blender \
@@ -668,7 +667,7 @@ elseif(WIN32)
                        set(PYTHON_VERSION 3.2)
                        set(PYTHON_INCLUDE_DIRS "${PYTHON}/include/python${PYTHON_VERSION}")
                        # set(PYTHON_BINARY python) # not used yet
-                       set(PYTHON_LIBRARY python32)
+                       set(PYTHON_LIBRARIES python32)
                        set(PYTHON_LIBPATH ${PYTHON}/lib)
                endif()
 
@@ -775,7 +774,7 @@ elseif(WIN32)
                        set(PYTHON_VERSION 3.2)
                        set(PYTHON_INCLUDE_DIRS "${PYTHON}/include/python${PYTHON_VERSION}")
                        # set(PYTHON_BINARY python) # not used yet
-                       set(PYTHON_LIBRARY python32mw)
+                       set(PYTHON_LIBRARIES python32mw)
                        set(PYTHON_LIBPATH ${PYTHON}/lib)
                endif()
 
@@ -835,7 +834,7 @@ elseif(APPLE)
                set(PYTHON ${LIBDIR}/python)
                set(PYTHON_INCLUDE_DIRS "${PYTHON}/include/python${PYTHON_VERSION}")
                # set(PYTHON_BINARY "${PYTHON}/bin/python${PYTHON_VERSION}") # not used yet
-               set(PYTHON_LIBRARY python${PYTHON_VERSION})
+               set(PYTHON_LIBRARIES python${PYTHON_VERSION})
                set(PYTHON_LIBPATH "${PYTHON}/lib/python${PYTHON_VERSION}")
                # set(PYTHON_LINKFLAGS "-u _PyMac_Error")  # won't  build with this enabled
        else()
@@ -845,7 +844,7 @@ elseif(APPLE)
                set(PYTHON_VERSION 3.2)
                set(PYTHON_INCLUDE_DIRS "${PYTHON}${PYTHON_VERSION}/include/python${PYTHON_VERSION}")
                # set(PYTHON_BINARY ${PYTHON}${PYTHON_VERSION}/bin/python${PYTHON_VERSION}) # not used yet
-               set(PYTHON_LIBRARY "")
+               set(PYTHON_LIBRARIES "")
                set(PYTHON_LIBPATH ${PYTHON}${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config)
                set(PYTHON_LINKFLAGS "-u _PyMac_Error -framework System -framework Python")
        endif()
index 729771f..07d95a5 100644 (file)
@@ -2,7 +2,7 @@
 #
 #  PYTHON_VERSION
 #  PYTHON_INCLUDE_DIRS
-#  PYTHON_LIBRARY
+#  PYTHON_LIBRARIES
 #  PYTHON_LIBPATH
 #  PYTHON_LINKFLAGS
 #  PYTHON_ROOT_DIR, The base directory to search for Python.
@@ -45,18 +45,18 @@ foreach(_CURRENT_ABI_FLAGS ${_python_ABI_FLAGS})
                PATH_SUFFIXES include/python${PYTHON_VERSION}${_CURRENT_ABI_FLAGS}
        )
 
-       find_library(PYTHON_LIBRARY
+       find_library(PYTHON_LIBRARIES
                NAMES "python${PYTHON_VERSION}${_CURRENT_ABI_FLAGS}"
                HINTS ${_python_SEARCH_DIRS}
                PATH_SUFFIXES lib64 lib
        )
 
-       if((EXISTS ${PYTHON_LIBRARY}) AND (EXISTS ${PYTHON_INCLUDE_DIR}))
+       if((EXISTS ${PYTHON_LIBRARIES}) AND (EXISTS ${PYTHON_INCLUDE_DIR}))
                break()
        else()
                # ensure we dont find values from 2 different ABI versions
                unset(PYTHON_INCLUDE_DIR CACHE)
-               unset(PYTHON_LIBRARY CACHE)
+               unset(PYTHON_LIBRARIES CACHE)
        endif()
 endforeach()
 
@@ -70,19 +70,19 @@ unset(_python_SEARCH_DIRS)
 # all listed variables are TRUE
 include(FindPackageHandleStandardArgs)
 FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonLibsUnix  DEFAULT_MSG
-    PYTHON_LIBRARY PYTHON_INCLUDE_DIR)
+    PYTHON_LIBRARIES PYTHON_INCLUDE_DIR)
 
 
 if(PYTHONLIBSUNIX_FOUND)
        # Assign cache items
        set(PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_DIR} CACHE STRING "")
-       set(PYTHON_LIBRARY ${PYTHON_LIBRARY} CACHE STRING "")
+       set(PYTHON_LIBRARIES ${PYTHON_LIBRARIES} CACHE STRING "")
        # not used
        # set(PYTHON_BINARY ${PYTHON_EXECUTABLE} CACHE STRING "")
 
        mark_as_advanced(
                PYTHON_INCLUDE_DIRS
                PYTHON_INCLUDE_DIR
-               PYTHON_LIBRARY
+               PYTHON_LIBRARIES
        )
 endif()
index 3776bbb..5e2db8e 100644 (file)
@@ -1,6 +1,44 @@
 # -*- mode: cmake; indent-tabs-mode: t; -*-
 # $Id$
 
+
+# foo_bar.spam --> foo_barMySuffix.spam
+macro(file_suffix
+       file_name_new file_name file_suffix
+       )
+
+       get_filename_component(_file_name_PATH ${file_name} PATH)
+       get_filename_component(_file_name_NAME_WE ${file_name} NAME_WE)
+       get_filename_component(_file_name_EXT ${file_name} EXT)
+       set(${file_name_new} "${_file_name_PATH}/${_file_name_NAME_WE}${file_suffix}${_file_name_EXT}")
+
+       unset(_file_name_PATH)
+       unset(_file_name_NAME_WE)
+       unset(_file_name_EXT)
+endmacro()
+
+# usefil for adding debug suffix to library lists:
+# /somepath/foo.lib --> /somepath/foo_d.lib
+macro(file_list_suffix
+       fp_list_new fp_list fn_suffix
+       )
+
+       # incase of empty list
+       set(_fp)
+       set(_fp_suffixed)
+
+       set(fp_list_new)
+
+       foreach(_fp ${fp_list})
+               file_suffix(_fp_suffixed "${_fp}" "${fn_suffix}")
+               list(APPEND "${fp_list_new}" "${_fp_suffixed}")
+       endforeach()
+
+       unset(_fp)
+       unset(_fp_suffixed)
+
+endmacro()
+
 # Nicer makefiles with -I/1/foo/ instead of -I/1/2/3/../../foo/
 # use it instead of include_directories()
 macro(blender_include_dirs
@@ -163,11 +201,13 @@ macro(setup_liblinks
                target_link_libraries(${target} ${PYTHON_LINKFLAGS})
 
                if(WIN32 AND NOT UNIX)
+                       file_list_suffix(PYTHON_LIBRARIES_DEBUG "${PYTHON_LIBRARIES}" "_d")
                        target_link_libraries(${target}
-                                       debug ${PYTHON_LIBRARY}_d
-                                       optimized ${PYTHON_LIBRARY})
+                                       debug ${PYTHON_LIBRARIES_DEBUG}
+                                       optimized ${PYTHON_LIBRARIES})
+                       unset(PYTHON_LIBRARIES_DEBUG)
                else()
-                       target_link_libraries(${target} ${PYTHON_LIBRARY})
+                       target_link_libraries(${target} ${PYTHON_LIBRARIES})
                endif()
        endif()
 
@@ -216,14 +256,11 @@ macro(setup_liblinks
        endif()
        if(WITH_IMAGE_OPENEXR)
                if(WIN32 AND NOT UNIX)
-                       foreach(_LOOP_VAR ${OPENEXR_LIBRARIES})
-                               string(REGEX REPLACE ".lib$" "_d.lib" _LOOP_VAR_DEBUG ${_LOOP_VAR})
-                               target_link_libraries(${target}
-                                               debug ${_LOOP_VAR_DEBUG}
-                                               optimized ${_LOOP_VAR})
-                       endforeach()
-                       unset(_LOOP_VAR)
-                       unset(_LOOP_VAR_DEBUG)
+                       file_list_suffix(OPENEXR_LIBRARIES_DEBUG "${OPENEXR_LIBRARIES}" "_d")
+                       target_link_libraries(${target}
+                                       debug ${OPENEXR_LIBRARIES_DEBUG}
+                                       optimized ${OPENEXR_LIBRARIES})
+                       unset(OPENEXR_LIBRARIES_DEBUG)
                else()
                        target_link_libraries(${target} ${OPENEXR_LIBRARIES})
                endif()
@@ -236,19 +273,24 @@ macro(setup_liblinks
        endif()
        if(WITH_OPENCOLLADA)
                if(WIN32 AND NOT UNIX)
-                       foreach(_LOOP_VAR ${OPENCOLLADA_LIBRARIES})
-                               target_link_libraries(${target}
-                                               debug ${_LOOP_VAR}_d
-                                               optimized ${_LOOP_VAR})
-                       endforeach()
-                       unset(_LOOP_VAR)
+                       file_list_suffix(OPENCOLLADA_LIBRARIES_DEBUG "${OPENCOLLADA_LIBRARIES}" "_d")
+                       target_link_libraries(${target}
+                                       debug ${OPENCOLLADA_LIBRARIES_DEBUG}
+                                       optimized ${OPENCOLLADA_LIBRARIES})
+                       unset(OPENCOLLADA_LIBRARIES_DEBUG)
+
+                       file_list_suffix(PCRE_LIB_DEBUG "${PCRE_LIB}" "_d")
                        target_link_libraries(${target}
-                                       debug ${PCRE_LIB}_d
+                                       debug ${PCRE_LIB_DEBUG}
                                        optimized ${PCRE_LIB})
+                       unset(PCRE_LIB_DEBUG)
+
                        if(EXPAT_LIB)
+                               file_list_suffix(EXPAT_LIB_DEBUG "${EXPAT_LIB}" "_d")
                                target_link_libraries(${target}
-                                               debug ${EXPAT_LIB}_d
+                                               debug ${EXPAT_LIB_DEBUG}
                                                optimized ${EXPAT_LIB})
+                               unset(EXPAT_LIB_DEBUG)
                        endif()
                else()
                        target_link_libraries(${target}
index 10bcbee..5da2464 100644 (file)
@@ -776,7 +776,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd,
 {
        DerivedMesh *explode, *dm=to_explode;
        MFace *mf= NULL, *mface;
-       ParticleSettings *part=psmd->psys->part;
+       /* ParticleSettings *part=psmd->psys->part; */ /* UNUSED */
        ParticleSimulationData sim= {NULL};
        ParticleData *pa=NULL, *pars=psmd->psys->particles;
        ParticleKey state, birth;