Add const typedef for osl_strings
[openscop.git] / CMakeLists.txt
blob69288a753ad700991b74bbde3144c68ef124c7f0
1 cmake_minimum_required(VERSION 2.6)
4 set(PACKAGE_VERSION "0.8.4")
5 set(top_srcdir "${CMAKE_CURRENT_SOURCE_DIR}")
8 # User's settings - C Flags
10 #       set(release "TRUE")
11         set(release "FALSE")
13         # Release
14         if (release)
15                 set(CMAKE_C_FLAGS "-O3")
16         # Debug # valgrind --show-reachable=yes --leak-check=full -v exe
17         else()
18                 set(CMAKE_C_FLAGS "-O0 -g3")
19         endif()
21 # User's settings - General C Flags
22         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -std=c99 -pedantic")
25 # Build doxygen
26         find_package(Doxygen)
27         if(DOXYGEN_FOUND)
28                 configure_file("doc/Doxyfile.in" "Doxyfile")
29                 add_custom_target(
30                         doxygen
31                         ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
32                         WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
33                         COMMENT "Generating API documentation with Doxygen" VERBATIM
34                 )
35         else()
36                 message (STATUS "Doxygen not found :( API documentation can not be built")
37         endif()
39 # Build documentation
40         find_program(texi2pdf_exe texi2pdf)
41         if(texi2pdf_exe)
42                 add_custom_target(
43                         doc
44                         ${texi2pdf_exe} ${CMAKE_CURRENT_SOURCE_DIR}/doc/openscop.texi --output=${CMAKE_CURRENT_BINARY_DIR}/openscop.pdf
45                         WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
46                         COMMENT "Generating documentation (pdf) (with texi2pdf)" VERBATIM
47                 )
48         else()
49                 message (STATUS "texi2pdf not found :( Documentation can not be built")
50         endif()
53 # GMP
54         message(STATUS "---")
55         find_library(gmp_LIB gmp)
56         if (gmp_LIB)
57                 message (STATUS "Library gmp found =) ${gmp_LIB}")
58                 add_definitions(-DOSL_GMP_IS_HERE)
59         else()
60                 message(STATUS "Library gmp not found :(")
61         endif()
63 # Include directories (to use #include <> instead of #include "")
65         # include/osl/scop.h
66         configure_file("include/osl/scop.h.in" "include/osl/scop.h")
67         include_directories("${CMAKE_CURRENT_BINARY_DIR}/include")
68         # osl
69         set(osl_INCLUDE "./include")
70         message(STATUS "Include osl = ${osl_INCLUDE}")
71         include_directories("${osl_INCLUDE}")
74 # Compiler log
75         message(STATUS "---")
76         message(STATUS "C compiler = ${CMAKE_C_COMPILER}")
77         if (release)
78                 message(STATUS "Mode Release")
79         else()
80                 message(STATUS "Mode Debug")
81         endif()
82         message(STATUS "C flags    = ${CMAKE_C_FLAGS}")
85 # files .c
86         file(
87                 GLOB_RECURSE
88                 sources
89                 source/*
90         )
91         
92 # Library
94         # Shared
95         add_library(
96                 osl
97                 SHARED
98                 ${sources}
99         )
100         if (gmp_LIB)
101                 target_link_libraries(osl ${gmp_LIB})
102         endif()
103         get_property(osl_lib_location TARGET osl PROPERTY LOCATION)
104         message(STATUS "Add osl library (shared) ${osl_lib_location}")
105         
106         # Static
107         add_library(
108                 osl_static
109                 STATIC
110                 ${sources}
111         )
112         set_target_properties(osl_static PROPERTIES OUTPUT_NAME osl)
113         if (gmp_LIB)
114                 target_link_libraries(osl_static ${gmp_LIB})
115         endif()
116         get_property(osl_static_lib_location TARGET osl_static PROPERTY LOCATION)
117         message(STATUS "Add osl library (static) ${osl_static_lib_location}")
120 # Executables & tests
122         enable_testing()
124         message(STATUS "---") # osl_test
126         set(exe "osl_test")
127         message(STATUS "Add executable tests/${exe}")
128         add_executable(${exe} "tests/${exe}.c")
129         target_link_libraries(${exe} osl_static)
130         add_test(${exe} "${exe}")
132         message(STATUS "---")
135 # Install
137         install(TARGETS osl LIBRARY DESTINATION lib)
138         install(TARGETS osl_static ARCHIVE DESTINATION lib)
139         install(DIRECTORY include/ DESTINATION include FILES_MATCHING PATTERN "*.h")
140         install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include/" DESTINATION include FILES_MATCHING PATTERN "*.h")
141         install(FILES osl-config.cmake DESTINATION lib/osl)
144 # Little help
146         message(STATUS "You can execute:")
147         message(STATUS "    make         # To compile osl library")
148         message(STATUS "    make test    # To execute tests")
149         message(STATUS "    make install # To install library, include and CMake module")
150         message(STATUS "                 # If you need root access:")
151         message(STATUS "                 #     sudo make install")
152         message(STATUS "                 #     su -c \"make install\"")
153         if(DOXYGEN_FOUND)
154                 message(STATUS "    make doxygen # To generate the Doxygen")
155         endif()
156         if(texi2pdf_exe)
157                 message(STATUS "    make doc     # To generate the documentation")
158         endif()
160         message(STATUS "---")