CMake lists initial submission. Documentationand further verification for different...
[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_SOURCE_DIR}/cmake_blender_libs.txt "${name};")
38 ENDMACRO(BLENDERLIB)
39
40 MACRO(SETUP_LIBDIRS)
41   LINK_DIRECTORIES(${PYTHON_LIBPATH} ${SDL_LIBPATH} ${JPEG_LIBPATH} ${PNG_LIBPATH} ${ZLIB_LIBPATH} ${ICONV_LIBPATH} ${OPENEXR_LIBPATH} ${FFMPEG_LIBPATH})
42   IF(WITH_INTERNATIONAL)
43     LINK_DIRECTORIES(${GETTEXT_LIBPATH})
44     LINK_DIRECTORIES(${FREETYPE_LIBPATH})
45   ENDIF(WITH_INTERNATIONAL)
46   IF(WITH_OPENAL)
47     LINK_DIRECTORIES(${OPENAL_LIBPATH})
48   ENDIF(WITH_OPENAL)
49
50   IF(WIN32)
51     LINK_DIRECTORIES(${PTHREADS_LIBPATH})
52   ENDIF(WIN32)
53 ENDMACRO(SETUP_LIBDIRS)
54
55 MACRO(SETUP_LIBLINKS
56   target)
57   SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PLATFORM_LINKFLAGS} ")
58   TARGET_LINK_LIBRARIES(${target} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${PYTHON_LIB} ${PYTHON_LINKFLAGS} ${JPEG_LIB} ${PNG_LIB} ${ZLIB_LIB} ${SDL_LIB} ${LLIBS})
59   IF(WITH_INTERNATIONAL)
60     TARGET_LINK_LIBRARIES(${target} ${FREETYPE_LIB})
61     TARGET_LINK_LIBRARIES(${target} ${GETTEXT_LIB})
62   ENDIF(WITH_INTERNATIONAL)
63   IF(WITH_OPENAL)
64     TARGET_LINK_LIBRARIES(${target} ${OPENAL_LIB})
65   ENDIF(WITH_OPENAL)
66   IF(WIN32)
67     TARGET_LINK_LIBRARIES(${target} ${ICONV_LIB})
68   ENDIF(WIN32)
69   IF(WITH_OPENEXR)
70     TARGET_LINK_LIBRARIES(${target} ${OPENEXR_LIB})
71   ENDIF(WITH_OPENEXR)
72   IF(WITH_FFMPEG)
73     TARGET_LINK_LIBRARIES(${target} ${FFMPEG_LIB})
74   ENDIF(WITH_FFMPEG)
75   IF(WIN32)
76     TARGET_LINK_LIBRARIES(${target} ${PTHREADS_LIB})
77   ENDIF(WIN32)
78 ENDMACRO(SETUP_LIBLINKS)