fixed: compile issue
[opensg.git] / Support / libpng / CMakeLists.txt
blobf688f164e044128c2488bada32e63a12b110a997
1 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
3 IF(OSGLibPNGSrcDir AND OSGZLibSrcDir)
5   MESSAGE(STATUS "adding libpng from : ${OSGLibPNGSrcDir}")
7   PROJECT(OSGLibPNG)
9   SET(${PROJECT_NAME}SharedTarget osgpng)
10   SET(${PROJECT_NAME}StaticTarget libosgpng)
12   SET(OSG_LIBPNG_SRCS ${OSGLibPNGSrcDir}/png.c
13                       ${OSGLibPNGSrcDir}/pngerror.c
14                       ${OSGLibPNGSrcDir}/pngget.c
15                       ${OSGLibPNGSrcDir}/pngmem.c
16                       ${OSGLibPNGSrcDir}/pngpread.c
17                       ${OSGLibPNGSrcDir}/pngread.c
18                       ${OSGLibPNGSrcDir}/pngrio.c
19                       ${OSGLibPNGSrcDir}/pngrtran.c
20                       ${OSGLibPNGSrcDir}/pngrutil.c
21                       ${OSGLibPNGSrcDir}/pngset.c
22                       ${OSGLibPNGSrcDir}/pngtrans.c
23                       ${OSGLibPNGSrcDir}/pngwio.c
24                       ${OSGLibPNGSrcDir}/pngwrite.c
25                       ${OSGLibPNGSrcDir}/pngwtran.c
26                       ${OSGLibPNGSrcDir}/pngwutil.c)
28   IF(EXISTS ${OSGLibPNGSrcDir}/scripts/pngw32.def)
29     SET(OSG_LIBPNG_SRCS ${OSG_LIBPNG_SRCS} 
30                         ${OSGLibPNGSrcDir}/scripts/pngw32.def)
31   ELSE()
32     SET(OSG_LIBPNG_SRCS ${OSG_LIBPNG_SRCS} 
33                         ${CMAKE_CURRENT_SOURCE_DIR}/symbols.def)
34   ENDIF()
36   SET(OSG_LIBPNG_HDR ${OSGLibPNGSrcDir}/png.h 
37                      ${OSGLibPNGSrcDir}/pngconf.h)
39   IF(EXISTS ${OSGLibPNGSrcDir}/scripts/pnglibconf.h.prebuilt)
40     EXECUTE_PROCESS(
41       COMMAND "${CMAKE_COMMAND}" -E copy_if_different
42                        "${OSGLibPNGSrcDir}/scripts/pnglibconf.h.prebuilt"
43                        "${OSGLibPNGSrcDir}/pnglibconf.h")
45     SET(OSG_LIBPNG_HDR ${OSG_LIBPNG_HDR} ${OSGLibPNGSrcDir}/pnglibconf.h)
46   ENDIF()
48   INCLUDE_DIRECTORIES(${OSG_ZLIB_INCLUDE_DIR})
50   IF(BUILD_SHARED_LIBS)
51     ADD_LIBRARY(${${PROJECT_NAME}SharedTarget} SHARED ${OSG_LIBPNG_SRCS})
53     ADD_DEPENDENCIES(ALL_STANDARD_BUILD ${${PROJECT_NAME}SharedTarget})
55     SET_TARGET_PROPERTIES(${${PROJECT_NAME}SharedTarget} PROPERTIES
56                           DEFINE_SYMBOL PNG_BUILD_DLL   
57                           DEBUG_POSTFIX "D")
59     SET(OSGPNGLIB_DEF_SHARED ZLIB_DLL)
61     SET_TARGET_PROPERTIES(${${PROJECT_NAME}SharedTarget} PROPERTIES
62                           COMPILE_DEFINITIONS "${OSGPNGLIB_DEF_SHARED}")
64     TARGET_LINK_LIBRARIES(${${PROJECT_NAME}SharedTarget} osgzlib)
66     INSTALL(TARGETS ${${PROJECT_NAME}SharedTarget}
67                 CONFIGURATIONS Release 
68                 RUNTIME DESTINATION bin COMPONENT release_runtimes
69                 LIBRARY DESTINATION lib COMPONENT release_libraries
70                 ARCHIVE DESTINATION lib COMPONENT release_libraries)
72     INSTALL(TARGETS ${${PROJECT_NAME}SharedTarget}
73                 CONFIGURATIONS Debug
74                 RUNTIME DESTINATION bin COMPONENT debug_runtimes
75                 LIBRARY DESTINATION lib COMPONENT debug_libraries
76                 ARCHIVE DESTINATION lib COMPONENT debug_libraries)
77   ENDIF(BUILD_SHARED_LIBS)
79   IF(BUILD_STATIC_LIBS)
80     ADD_LIBRARY(${${PROJECT_NAME}StaticTarget} STATIC ${OSG_LIBPNG_SRCS})
82     ADD_DEPENDENCIES(ALL_STANDARD_BUILD ${${PROJECT_NAME}StaticTarget})
84     SET_TARGET_PROPERTIES(${${PROJECT_NAME}StaticTarget} PROPERTIES
85                           DEBUG_POSTFIX "D")
87     INSTALL(TARGETS ${${PROJECT_NAME}StaticTarget}
88                 CONFIGURATIONS Release
89                 RUNTIME DESTINATION lib COMPONENT release_libraries
90                 LIBRARY DESTINATION lib COMPONENT release_libraries
91                 ARCHIVE DESTINATION lib COMPONENT release_libraries)
93     INSTALL(TARGETS ${${PROJECT_NAME}StaticTarget}
94                 CONFIGURATIONS Debug
95                 RUNTIME DESTINATION lib COMPONENT debug_libraries
96                 LIBRARY DESTINATION lib COMPONENT debug_libraries
97                 ARCHIVE DESTINATION lib COMPONENT debug_libraries)
98   ENDIF(BUILD_STATIC_LIBS)
100   INSTALL(FILES ${OSG_LIBPNG_HDR}
101           DESTINATION include${OSG_SUPPORT_INC_SUBDIR}
102           COMPONENT code_headers
103           PERMISSIONS OWNER_WRITE OWNER_READ
104                       GROUP_READ
105                       WORLD_READ)
107   SET(OSG_PNG_INCLUDE_DIR ${OSGLibPNGSrcDir} CACHE PATH "")
108   SET(OSG_PNG_STATIC_LIBRARY ${${PROJECT_NAME}StaticTarget} CACHE STRING "")
109   SET(OSG_PNG_SHARED_LIBRARY ${${PROJECT_NAME}SharedTarget} CACHE STRING "")
111 ELSE(OSGLibPNGSrcDir AND OSGZLibSrcDir)
112   MESSAGE(STATUS "ignoring libpng")
114   SET(OSGLibPNGSrcDir "" CACHE PATH "")
115 ENDIF(OSGLibPNGSrcDir AND OSGZLibSrcDir)