History

Enable tests, examples and install per default if libsamplerate is root project

Closes #46

Flamefire committed 7 years ago

Commit af1d8841 parent 0b3d1db1 file · +28 −19Browse files

Unified · Split

CMakeLists.txt+28−19
@@ -1,10 +1,17 @@
1cmake_minimum_required(VERSION 3.1)1cmake_minimum_required(VERSION 3.1)
2project(libsamplerate VERSION 0.1.9 LANGUAGES C)2project(libsamplerate VERSION 0.1.9 LANGUAGES C)
3 3
4option(LIBSAMPLERATE_TESTS "Enable to generate test targets" ON)4if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
5option(LIBSAMPLERATE_INSTALL "Enable to add install directives" ON)5 set(LIBSAMPLERATE_IS_ROOT_PROJECT ON)
6else()
7 set(LIBSAMPLERATE_IS_ROOT_PROJECT OFF)
8endif()
9
10option(LIBSAMPLERATE_TESTS "Enable to generate test targets" ${LIBSAMPLERATE_IS_ROOT_PROJECT})
11option(LIBSAMPLERATE_EXAMPLES "Enable to generate examples" ${LIBSAMPLERATE_IS_ROOT_PROJECT})
12option(LIBSAMPLERATE_INSTALL "Enable to add install directives" ${LIBSAMPLERATE_IS_ROOT_PROJECT})
6 13
7set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)14list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
8 15
9include(TestBigEndian)16include(TestBigEndian)
10include(CheckFunctionExists)17include(CheckFunctionExists)
@@ -104,7 +111,7 @@ endif() · 93 unmodified lines
104 111
105if(LIBSAMPLERATE_TESTS)112if(LIBSAMPLERATE_TESTS)
106 113
107enable_testing()114 enable_testing()
108 115
109file(GLOB TEST_SRCS ${PROJECT_SOURCE_DIR}/tests/*_test.c)116file(GLOB TEST_SRCS ${PROJECT_SOURCE_DIR}/tests/*_test.c)
110 117
@@ -117,10 +124,12 @@ foreach(testSrc ${TEST_SRCS}) · 6 unmodified lines
117 target_link_libraries(${testName} PUBLIC samplerate)124 target_link_libraries(${testName} PUBLIC samplerate)
118 if(FFTW_FOUND)125 if(FFTW_FOUND)
119 target_link_libraries(${testName} PUBLIC ${FFTW_LIBRARY})126 target_link_libraries(${testName} PUBLIC ${FFTW_LIBRARY})
120 endif()127endif()
121 add_test(NAME ${testName} COMMAND ${testName})128 add_test(NAME ${testName} COMMAND ${testName})
122endforeach(testSrc)129endforeach(testSrc)
130endif()
123 131
132if(LIBSAMPLERATE_EXAMPLES)
124set(EXAMPLE_SRCS133set(EXAMPLE_SRCS
125 ${PROJECT_SOURCE_DIR}/examples/timewarp-file.c134 ${PROJECT_SOURCE_DIR}/examples/timewarp-file.c
126 ${PROJECT_SOURCE_DIR}/examples/varispeed-play.c)135 ${PROJECT_SOURCE_DIR}/examples/varispeed-play.c)
@@ -147,19 +156,19 @@ endforeach(exampleSrc) · 20 unmodified lines
147endif() 156endif()
148 157
149if(LIBSAMPLERATE_INSTALL)158if(LIBSAMPLERATE_INSTALL)
150set(prefix ${CMAKE_INSTALL_PREFIX})159 set(prefix ${CMAKE_INSTALL_PREFIX})
151set(exec_prefix "\${prefix}")160 set(exec_prefix "\${prefix}")
152set(includedir "\${prefix}/include")161 set(includedir "\${prefix}/include")
153set(libdir "\${exec_prefix}/lib")162 set(libdir "\${exec_prefix}/lib")
154set(VERSION "${PROJECT_VERSION}")163 set(VERSION "${PROJECT_VERSION}")
155if(NEED_MATH)164 if(NEED_MATH)
156 set(LIBS "-lm")165 set(LIBS "-lm")
157endif()166 endif()
158configure_file(samplerate.pc.in samplerate.pc @ONLY)167 configure_file(samplerate.pc.in samplerate.pc @ONLY)
159 168
160install(TARGETS samplerate DESTINATION lib)169 install(TARGETS samplerate DESTINATION lib)
161install(FILES src/samplerate.h DESTINATION include)170 install(FILES src/samplerate.h DESTINATION include)
162install(DIRECTORY doc/ DESTINATION share/doc/libsamplerate)171 install(DIRECTORY doc/ DESTINATION share/doc/libsamplerate)
163install(FILES ${CMAKE_BINARY_DIR}/samplerate.pc DESTINATION lib/pkgconfig)172 install(FILES ${CMAKE_BINARY_DIR}/samplerate.pc DESTINATION lib/pkgconfig)
164 173
165endif()174endif()

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t