diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-06-19 10:57:56 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-06-19 10:57:56 +0400 |
commit | 145944d66f8364c82bdc83dcd57774284b775add (patch) | |
tree | b1b0e28d008402c3d379b644321648b4f95977ef /build_files/cmake | |
parent | f31bae0aabe47b928a8c77020a798e815ed8b70f (diff) |
cmake:
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.
Diffstat (limited to 'build_files/cmake')
-rw-r--r-- | build_files/cmake/Modules/FindPythonLibsUnix.cmake | 14 | ||||
-rw-r--r-- | build_files/cmake/macros.cmake | 80 |
2 files changed, 68 insertions, 26 deletions
diff --git a/build_files/cmake/Modules/FindPythonLibsUnix.cmake b/build_files/cmake/Modules/FindPythonLibsUnix.cmake index 729771f0a52..07d95a53dc2 100644 --- a/build_files/cmake/Modules/FindPythonLibsUnix.cmake +++ b/build_files/cmake/Modules/FindPythonLibsUnix.cmake @@ -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() diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 3776bbb7ecc..5e2db8edc47 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -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} |