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
15 set(CMAKE_C_FLAGS "-O3")
16 # Debug # valgrind --show-reachable=yes --leak-check=full -v exe
18 set(CMAKE_C_FLAGS "-O0 -g3")
21 # User's settings - General C Flags
22 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -std=c99 -pedantic")
28 configure_file("doc/Doxyfile.in" "Doxyfile")
31 ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
32 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
33 COMMENT "Generating API documentation with Doxygen" VERBATIM
36 message (STATUS "Doxygen not found :( API documentation can not be built")
40 find_program(texi2pdf_exe texi2pdf)
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
49 message (STATUS "texi2pdf not found :( Documentation can not be built")
55 find_library(gmp_LIB gmp)
57 message (STATUS "Library gmp found =) ${gmp_LIB}")
58 add_definitions(-DOSL_GMP_IS_HERE)
60 message(STATUS "Library gmp not found :(")
63 # Include directories (to use #include <> instead of #include "")
66 configure_file("include/osl/scop.h.in" "include/osl/scop.h")
67 include_directories("${CMAKE_CURRENT_BINARY_DIR}/include")
69 set(osl_INCLUDE "./include")
70 message(STATUS "Include osl = ${osl_INCLUDE}")
71 include_directories("${osl_INCLUDE}")
76 message(STATUS "C compiler = ${CMAKE_C_COMPILER}")
78 message(STATUS "Mode Release")
80 message(STATUS "Mode Debug")
82 message(STATUS "C flags = ${CMAKE_C_FLAGS}")
101 target_link_libraries(osl ${gmp_LIB})
103 get_property(osl_lib_location TARGET osl PROPERTY LOCATION)
104 message(STATUS "Add osl library (shared) ${osl_lib_location}")
112 set_target_properties(osl_static PROPERTIES OUTPUT_NAME osl)
114 target_link_libraries(osl_static ${gmp_LIB})
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
136 message(STATUS "---")
138 foreach(test_source ${tests})
140 string(REPLACE ".c" "" test_name ${test_source})
141 string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/tests/" "test__" test_name ${test_name})
143 message(STATUS "Add executable tests/${test_name}")
144 add_executable(${test_name} "${test_source}")
145 target_link_libraries(${test_name} osl_static)
147 if (${test_name} STREQUAL "test__osl_test")
148 foreach (scop ${scops})
149 string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/tests/" "" scop_name ${scop})
150 message(STATUS "- ${scop_name}")
151 add_test("${test_name}__${scop_name}" "${test_name}" "${scop}")
154 add_test("${test_name}" "${test_name}")
159 message(STATUS "---")
164 install(TARGETS osl LIBRARY DESTINATION lib)
165 install(TARGETS osl_static ARCHIVE DESTINATION lib)
166 install(DIRECTORY include/ DESTINATION include FILES_MATCHING PATTERN "*.h")
167 install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include/" DESTINATION include FILES_MATCHING PATTERN "*.h")
168 install(FILES osl-config.cmake DESTINATION lib/osl)
173 message(STATUS "You can execute:")
174 message(STATUS " make # To compile osl library")
175 message(STATUS " make test # To execute tests")
176 message(STATUS " make install # To install library, include and CMake module")
177 message(STATUS " # If you need root access:")
178 message(STATUS " # sudo make install")
179 message(STATUS " # su -c \"make install\"")
181 message(STATUS " make doxygen # To generate the Doxygen")
184 message(STATUS " make doc # To generate the documentation")
187 message(STATUS "---")