CMakeLists.txt 4.06 KB
Newer Older
Nick Sharp's avatar
Nick Sharp committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
cmake_minimum_required(VERSION 2.8)

include_directories(${PROJECT_SOURCE_DIR}/include/CMU462)

# CMU462 library source files
set(CMU462_SOURCE
    vector2D.cpp
    vector3D.cpp
    vector4D.cpp
    matrix3x3.cpp
    matrix4x4.cpp
    quaternion.cpp
    complex.cpp
    color.cpp
    spectrum.cpp
    osdtext.cpp
    osdfont.cpp
    viewer.cpp
    base64.cpp
    lodepng.cpp
    tinyxml2.cpp
)

#-------------------------------------------------------------------------------
# Building static library (always)
#-------------------------------------------------------------------------------
add_library(CMU462 STATIC ${CMU462_SOURCE})

target_link_libraries(
  CMU462
  ${GLEW_LIBRARIES}
  ${GLFW_LIBRARIES}
  ${OPENGL_LIBRARIES}
  ${FREETYPE_LIBRARIES}
)

#-------------------------------------------------------------------------------
# Building shared library
#-------------------------------------------------------------------------------
if(CMU462_BUILD_SHARED)
  add_library(CMU462_SHARED SHARED ${CMU462_SOURCE})
  target_link_libraries(
    CMU462_SHARED
    ${GLEW_LIBRARIES}
    ${GLFW_LIBRARIES}
    ${OPENGL_LIBRARIES}
    ${FREETYPE_LIBRARIES}
  )
endif()

#-------------------------------------------------------------------------------
# Platform-specific target configurations
#-------------------------------------------------------------------------------

###################
# Building on OSX #
###################
if (APPLE)

  # Clang options
  target_compile_options(CMU462 PRIVATE -Wno-constant-conversion)

  # Framework dependencies
  target_link_libraries(CMU462
    ${COCOA_LIBRARIES}
    ${IOKIT_LIBRARIES}
    ${COREVIDEO_LIBRARIES})

  # Output name
  if(CMU462_BUILD_DEBUG)
    set_target_properties(CMU462 PROPERTIES OUTPUT_NAME CMU462_osx_d)
    if(CMU462_BUILD_SHARED)
      set_target_properties(CMU462_SHARED PROPERTIES OUTPUT_NAME CMU462_osx_d)
    endif()
  else(CMU462_BUILD_DEBUG)
    set_target_properties(CMU462 PROPERTIES OUTPUT_NAME CMU462_osx)
    if(CMU462_BUILD_SHARED)
      set_target_properties(CMU462_SHARED PROPERTIES OUTPUT_NAME CMU462_osx)
    endif()
  endif(CMU462_BUILD_DEBUG)

endif(APPLE)

##################
# Build on Linux #
##################
set(LINUX UNIX AND NOT APPLE)
if(LINUX)
  if(CMU462_BUILD_DEBUG)
    set_target_properties(CMU462 PROPERTIES OUTPUT_NAME CMU462_d)
    if(CMU462_BUILD_SHARED)
      set_target_properties(CMU462_SHARED PROPERTIES OUTPUT_NAME CMU462_d)
    endif()
  else(CMU462_BUILD_DEBUG)
    set_target_properties(CMU462 PROPERTIES OUTPUT_NAME CMU462)
    if(CMU462_BUILD_SHARED)
      set_target_properties(CMU462_SHARED PROPERTIES OUTPUT_NAME CMU462)
    endif()
  endif(CMU462_BUILD_DEBUG)
endif(LINUX)

####################
# Build on Windows #
####################
if(WIN32)

  if(MSVC)
    if(CMU462_BUILD_DEBUG)
      set_target_properties(CMU462 PROPERTIES OUTPUT_NAME CMU462_d)
      if(CMU462_BUILD_SHARED)
        set_target_properties(CMU462_SHARED PROPERTIES OUTPUT_NAME CMU462_d)
      endif()
    else(CMU462_BUILD_DEBUG)
      set_target_properties(CMU462 PROPERTIES OUTPUT_NAME CMU462)
      if(CMU462_BUILD_SHARED)
        set_target_properties(CMU462_SHARED PROPERTIES OUTPUT_NAME CMU462)
      endif()
    endif(CMU462_BUILD_DEBUG)
  endif(MSVC)

  if(MINGW)
    if(CMU462_BUILD_DEBUG)
      set_target_properties(CMU462 PROPERTIES OUTPUT_NAME CMU462_d)
      if(CMU462_BUILD_SHARED)
        set_target_properties(CMU462_SHARED PROPERTIES OUTPUT_NAME CMU462_d)
      endif()
    else(CMU462_BUILD_DEBUG)
      set_target_properties(CMU462 PROPERTIES OUTPUT_NAME CMU462)
      if(CMU462_BUILD_SHARED)
        set_target_properties(CMU462_SHARED PROPERTIES OUTPUT_NAME CMU462)
      endif()
    endif(CMU462_BUILD_DEBUG)
  endif(MINGW)

endif(WIN32)

#-------------------------------------------------------------------------------
# Installation configurations
#-------------------------------------------------------------------------------
install(TARGETS CMU462 DESTINATION lib)
if(CMU462_BUILD_SHARED)
  install(TARGETS CMU462_SHARED DESTINATION lib)
endif()

# install headers
install(FILES ${CMU462_HEADER} DESTINATION include/CMU462)