- check IF WIN32 AND NOT UNIX (for cygwin)
[blender.git] / build_files / cmake / macros.cmake
index 9237f01a950aefce8cca1f7a05faf90d0273b49c..0da1d6c37dcf77be774a01ed4c5236f3fb2fdedb 100644 (file)
@@ -1,45 +1,42 @@
 
-IF(MSVC)
-       # only MSVC uses SOURCE_GROUP
-       MACRO(BLENDERLIB_NOLIST
-               name
-               sources
-               includes)
-
-               MESSAGE(STATUS "Configuring library ${name}")
-
-               # Gather all headers
-               FILE(GLOB_RECURSE INC_ALL *.h)
-                        
-               INCLUDE_DIRECTORIES(${includes})
-               ADD_LIBRARY(${name} ${INC_ALL} ${sources})
-
-               # Group by location on disk
-               SOURCE_GROUP(Files FILES CMakeLists.txt)
-               SET(ALL_FILES ${sources} ${INC_ALL})
-               FOREACH(SRC ${ALL_FILES})
-                       STRING(REGEX REPLACE ${CMAKE_CURRENT_SOURCE_DIR} "Files" REL_DIR "${SRC}")
-                       STRING(REGEX REPLACE "[\\\\/][^\\\\/]*$" "" REL_DIR "${REL_DIR}")
-                       STRING(REGEX REPLACE "^[\\\\/]" "" REL_DIR "${REL_DIR}")
-                       IF(REL_DIR)
-                               SOURCE_GROUP(${REL_DIR} FILES ${SRC})
-                       ELSE(REL_DIR)
-                               SOURCE_GROUP(Files FILES ${SRC})
-                       ENDIF(REL_DIR)
-               ENDFOREACH(SRC)
-       ENDMACRO(BLENDERLIB_NOLIST)
-ELSE(MSVC)
-
-       MACRO(BLENDERLIB_NOLIST
-               name
-               sources
-               includes)
-
-               MESSAGE(STATUS "Configuring library ${name}")
-               INCLUDE_DIRECTORIES(${includes})
-               ADD_LIBRARY(${name} ${sources})
-       ENDMACRO(BLENDERLIB_NOLIST)
-ENDIF(MSVC)
+# only MSVC uses SOURCE_GROUP
+MACRO(BLENDERLIB_NOLIST
+       name
+       sources
+       includes)
+
+       MESSAGE(STATUS "Configuring library ${name}")
+
+       # Gather all headers
+       FILE(GLOB_RECURSE INC_ALL *.h)
+                
+       INCLUDE_DIRECTORIES(${includes})
+       ADD_LIBRARY(${name} ${INC_ALL} ${sources})
+
+       # Group by location on disk
+       SOURCE_GROUP("Source Files" FILES CMakeLists.txt)
+       SET(ALL_FILES ${sources} ${INC_ALL})
+       FOREACH(SRC ${ALL_FILES})
+               GET_FILENAME_COMPONENT(SRC_EXT ${SRC} EXT)
+               IF(${SRC_EXT} MATCHES ".h" OR ${SRC_EXT} MATCHES ".hpp") 
+                       SOURCE_GROUP("Header Files" FILES ${SRC})
+               ELSE()
+                       SOURCE_GROUP("Source Files" FILES ${SRC})
+               ENDIF()
+       ENDFOREACH(SRC)
+ENDMACRO(BLENDERLIB_NOLIST)
+
+#      # works fine but having the includes listed is helpful for IDE's (QtCreator/MSVC)
+#      MACRO(BLENDERLIB_NOLIST
+#              name
+#              sources
+#              includes)
+#
+#              MESSAGE(STATUS "Configuring library ${name}")
+#              INCLUDE_DIRECTORIES(${includes})
+#              ADD_LIBRARY(${name} ${sources})
+#      ENDMACRO(BLENDERLIB_NOLIST)
+
 
 MACRO(BLENDERLIB
        name
@@ -103,9 +100,9 @@ MACRO(SETUP_LIBDIRS)
                LINK_DIRECTORIES(${EXPAT_LIBPATH})
        ENDIF(WITH_OPENCOLLADA)
 
-       IF(WIN32)
+       IF(WIN32 AND NOT UNIX)
                LINK_DIRECTORIES(${PTHREADS_LIBPATH})
-       ENDIF(WIN32)
+       ENDIF(WIN32 AND NOT UNIX)
 ENDMACRO(SETUP_LIBDIRS)
 
 MACRO(SETUP_LIBLINKS
@@ -118,12 +115,12 @@ MACRO(SETUP_LIBLINKS
        IF(WITH_PYTHON)
                TARGET_LINK_LIBRARIES(${target} ${PYTHON_LINKFLAGS})
 
-               IF(WIN32)
+               IF(WIN32 AND NOT UNIX)
                        TARGET_LINK_LIBRARIES(${target} debug ${PYTHON_LIB}_d)
                        TARGET_LINK_LIBRARIES(${target} optimized ${PYTHON_LIB})
-               ELSE(WIN32)
+               ELSE(WIN32 AND NOT UNIX)
                        TARGET_LINK_LIBRARIES(${target} ${PYTHON_LIB})
-               ENDIF(WIN32)
+               ENDIF(WIN32 AND NOT UNIX)
        ENDIF(WITH_PYTHON)
 
        TARGET_LINK_LIBRARIES(${target} ${OPENGL_glu_LIBRARY} ${JPEG_LIB} ${PNG_LIB} ${ZLIB_LIB})
@@ -132,9 +129,9 @@ MACRO(SETUP_LIBLINKS
        IF(WITH_INTERNATIONAL)
                TARGET_LINK_LIBRARIES(${target} ${GETTEXT_LIB})
 
-               IF(WIN32)
+               IF(WIN32 AND NOT UNIX)
                        TARGET_LINK_LIBRARIES(${target} ${ICONV_LIB})
-               ENDIF(WIN32)
+               ENDIF(WIN32 AND NOT UNIX)
        ENDIF(WITH_INTERNATIONAL)
 
        IF(WITH_OPENAL)
@@ -159,14 +156,14 @@ MACRO(SETUP_LIBLINKS
                TARGET_LINK_LIBRARIES(${target} ${TIFF_LIBRARY})
        ENDIF(WITH_IMAGE_TIFF)
        IF(WITH_IMAGE_OPENEXR)
-               IF(WIN32)
+               IF(WIN32 AND NOT UNIX)
                        FOREACH(loop_var ${OPENEXR_LIB})
                                TARGET_LINK_LIBRARIES(${target} debug ${loop_var}_d)
                                TARGET_LINK_LIBRARIES(${target} optimized ${loop_var})
                        ENDFOREACH(loop_var)
-               ELSE(WIN32)
+               ELSE(WIN32 AND NOT UNIX)
                        TARGET_LINK_LIBRARIES(${target} ${OPENEXR_LIB})
-               ENDIF(WIN32)
+               ENDIF(WIN32 AND NOT UNIX)
        ENDIF(WITH_IMAGE_OPENEXR)
        IF(WITH_LCMS)
                TARGET_LINK_LIBRARIES(${target} ${LCMS_LIBRARY})
@@ -175,7 +172,7 @@ MACRO(SETUP_LIBLINKS
                TARGET_LINK_LIBRARIES(${target} ${FFMPEG_LIB})
        ENDIF(WITH_FFMPEG)
        IF(WITH_OPENCOLLADA)
-               IF(WIN32)
+               IF(WIN32 AND NOT UNIX)
                        FOREACH(loop_var ${OPENCOLLADA_LIB})
                                TARGET_LINK_LIBRARIES(${target} debug ${loop_var}_d)
                                TARGET_LINK_LIBRARIES(${target} optimized ${loop_var})
@@ -186,21 +183,21 @@ MACRO(SETUP_LIBLINKS
                                TARGET_LINK_LIBRARIES(${target} debug ${EXPAT_LIB}_d)
                                TARGET_LINK_LIBRARIES(${target} optimized ${EXPAT_LIB})
                        ENDIF(EXPAT_LIB)
-               ELSE(WIN32)
+               ELSE(WIN32 AND NOT UNIX)
                        TARGET_LINK_LIBRARIES(${target} ${OPENCOLLADA_LIB})
                        TARGET_LINK_LIBRARIES(${target} ${PCRE_LIB})
                        TARGET_LINK_LIBRARIES(${target} ${EXPAT_LIB})
-               ENDIF(WIN32)
+               ENDIF(WIN32 AND NOT UNIX)
        ENDIF(WITH_OPENCOLLADA)
        IF(WITH_LCMS)
-               IF(WIN32)
+               IF(WIN32 AND NOT UNIX)
                        TARGET_LINK_LIBRARIES(${target} debug ${LCMS_LIB}_d)
                        TARGET_LINK_LIBRARIES(${target} optimized ${LCMS_LIB})
-               ENDIF(WIN32)
+               ENDIF(WIN32 AND NOT UNIX)
        ENDIF(WITH_LCMS)
-       IF(WIN32)
+       IF(WIN32 AND NOT UNIX)
                TARGET_LINK_LIBRARIES(${target} ${PTHREADS_LIB})
-       ENDIF(WIN32)
+       ENDIF(WIN32 AND NOT UNIX)
 ENDMACRO(SETUP_LIBLINKS)
 
 MACRO(TEST_SSE_SUPPORT)
@@ -238,6 +235,41 @@ MACRO(TEST_SSE_SUPPORT)
 
 ENDMACRO(TEST_SSE_SUPPORT)
 
+# when we have warnings as errors applied globally this
+# needs to be removed for some external libs which we dont maintain.
+
+# utility macro
+MACRO(_REMOVE_STRICT_FLAGS
+       flag)
+       
+       STRING(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
+       STRING(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
+       STRING(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
+       STRING(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS_MINSIZEREL ${CMAKE_C_FLAGS_MINSIZEREL})
+       STRING(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO})
+
+       STRING(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
+       STRING(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
+       STRING(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
+       STRING(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS_MINSIZEREL ${CMAKE_CXX_FLAGS_MINSIZEREL})
+       STRING(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
+
+ENDMACRO(_REMOVE_STRICT_FLAGS)
+
+MACRO(REMOVE_STRICT_FLAGS)
+
+       IF(CMAKE_COMPILER_IS_GNUCC)
+               _REMOVE_STRICT_FLAGS("-Wunused-parameter")
+               _REMOVE_STRICT_FLAGS("-Werror=[^ ]+")
+               _REMOVE_STRICT_FLAGS("-Werror")
+       ENDIF(CMAKE_COMPILER_IS_GNUCC)
+
+       IF(MSVC)
+               # TODO
+       ENDIF(MSVC)
+
+ENDMACRO(REMOVE_STRICT_FLAGS)
+
 
 MACRO(GET_BLENDER_VERSION)
        FILE(READ ${CMAKE_SOURCE_DIR}/source/blender/blenkernel/BKE_blender.h CONTENT)