NLA SoC: Merge from 2.5
[blender.git] / CMake / macros.cmake
1 MACRO(BLENDERLIB_NOLIST
2   name
3   sources
4   includes)
5
6   # Gather all headers
7   FILE(GLOB_RECURSE INC_ALL *.h)
8      
9   INCLUDE_DIRECTORIES(${includes})
10   ADD_LIBRARY(${name} ${INC_ALL} ${sources})
11
12   # Group by location on disk
13   SOURCE_GROUP(Files FILES CMakeLists.txt)
14   SET(ALL_FILES ${sources} ${INC_ALL})
15   FOREACH(SRC ${ALL_FILES})
16     STRING(REGEX REPLACE ${CMAKE_CURRENT_SOURCE_DIR} "Files" REL_DIR "${SRC}")
17     STRING(REGEX REPLACE "[\\\\/][^\\\\/]*$" "" REL_DIR "${REL_DIR}")
18     STRING(REGEX REPLACE "^[\\\\/]" "" REL_DIR "${REL_DIR}")
19     IF(REL_DIR)
20       SOURCE_GROUP(${REL_DIR} FILES ${SRC})
21     ELSE(REL_DIR)
22       SOURCE_GROUP(Files FILES ${SRC})
23     ENDIF(REL_DIR)
24   ENDFOREACH(SRC)
25
26   MESSAGE(STATUS "Configuring library ${name}")
27 ENDMACRO(BLENDERLIB_NOLIST)
28
29 MACRO(BLENDERLIB
30   name
31   sources
32   includes)
33
34   BLENDERLIB_NOLIST(${name} "${sources}" "${includes}")
35
36   # Add to blender's list of libraries
37   FILE(APPEND ${CMAKE_BINARY_DIR}/cmake_blender_libs.txt "${name};")
38 ENDMACRO(BLENDERLIB)
39
40 MACRO(SETUP_LIBDIRS)
41   # see "cmake --help-policy CMP0003"
42   if(COMMAND cmake_policy)
43     CMAKE_POLICY(SET CMP0003 NEW)
44   endif(COMMAND cmake_policy)
45   LINK_DIRECTORIES(${PYTHON_LIBPATH} ${SDL_LIBPATH} ${JPEG_LIBPATH} ${PNG_LIBPATH} ${ZLIB_LIBPATH} ${ICONV_LIBPATH} ${OPENEXR_LIBPATH} ${QUICKTIME_LIBPATH} ${FFMPEG_LIBPATH})
46   LINK_DIRECTORIES(${FREETYPE_LIBPATH})
47   IF(WITH_INTERNATIONAL)
48     LINK_DIRECTORIES(${GETTEXT_LIBPATH})
49   ENDIF(WITH_INTERNATIONAL)
50   IF(WITH_OPENAL)
51     LINK_DIRECTORIES(${OPENAL_LIBPATH})
52   ENDIF(WITH_OPENAL)
53
54   IF(WIN32)
55     LINK_DIRECTORIES(${PTHREADS_LIBPATH})
56   ENDIF(WIN32)
57 ENDMACRO(SETUP_LIBDIRS)
58
59 MACRO(SETUP_LIBLINKS
60   target)
61   SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PLATFORM_LINKFLAGS} ")
62   #TARGET_LINK_LIBRARIES(${target} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${PYTHON_LIB} ${PYTHON_LINKFLAGS} ${JPEG_LIB} ${PNG_LIB} ${ZLIB_LIB} ${SDL_LIB} ${LLIBS})
63
64   TARGET_LINK_LIBRARIES(${target} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${PYTHON_LINKFLAGS} ${JPEG_LIB} ${PNG_LIB} ${ZLIB_LIB} ${SDL_LIB} ${LLIBS})
65
66   # since we are using the local libs for python when compiling msvc projects, we need to add _d when compiling debug versions
67
68   IF(WIN32)
69
70             TARGET_LINK_LIBRARIES(${target} debug ${PYTHON_LIB}_d)
71
72             TARGET_LINK_LIBRARIES(${target} optimized ${PYTHON_LIB})
73
74   ELSE(WIN32)
75
76             TARGET_LINK_LIBRARIES(${target} ${PYTHON_LIB})
77
78   ENDIF(WIN32)
79
80
81   TARGET_LINK_LIBRARIES(${target} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${PYTHON_LINKFLAGS} ${JPEG_LIB} ${PNG_LIB} ${ZLIB_LIB} ${SDL_LIB} ${LLIBS})
82   TARGET_LINK_LIBRARIES(${target} ${FREETYPE_LIB})
83
84   # since we are using the local libs for python when compiling msvc projects, we need to add _d when compiling debug versions
85
86   IF(WIN32)
87
88             TARGET_LINK_LIBRARIES(${target} debug ${PYTHON_LIB}_d)
89
90             TARGET_LINK_LIBRARIES(${target} optimized ${PYTHON_LIB})
91
92             ELSE(WIN32)
93
94             TARGET_LINK_LIBRARIES(${target} ${PYTHON_LIB})
95
96   ENDIF(WIN32)
97
98   IF(WITH_INTERNATIONAL)
99     TARGET_LINK_LIBRARIES(${target} ${GETTEXT_LIB})
100   ENDIF(WITH_INTERNATIONAL)
101   IF(WITH_OPENAL)
102     TARGET_LINK_LIBRARIES(${target} ${OPENAL_LIB})
103   ENDIF(WITH_OPENAL)
104   IF(WIN32)
105     TARGET_LINK_LIBRARIES(${target} ${ICONV_LIB})
106   ENDIF(WIN32)
107   IF(WITH_QUICKTIME)
108     TARGET_LINK_LIBRARIES(${target} ${QUICKTIME_LIB})
109   ENDIF(WITH_QUICKTIME)
110   IF(WITH_OPENEXR)
111     TARGET_LINK_LIBRARIES(${target} ${OPENEXR_LIB})
112   ENDIF(WITH_OPENEXR)
113   IF(WITH_FFMPEG)
114     TARGET_LINK_LIBRARIES(${target} ${FFMPEG_LIB})
115   ENDIF(WITH_FFMPEG)
116   IF(WIN32)
117     TARGET_LINK_LIBRARIES(${target} ${PTHREADS_LIB})
118   ENDIF(WIN32)
119 ENDMACRO(SETUP_LIBLINKS)