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 @@
11 cmake_minimum_required(VERSION 3.1)
22 project(libsamplerate VERSION 0.1.9 LANGUAGES C)
33
4−option(LIBSAMPLERATE_TESTS "Enable to generate test targets" ON)
5−option(LIBSAMPLERATE_INSTALL "Enable to add install directives" ON)
4+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
5+ set(LIBSAMPLERATE_IS_ROOT_PROJECT ON)
6+else()
7+ set(LIBSAMPLERATE_IS_ROOT_PROJECT OFF)
8+endif()
9+
10+option(LIBSAMPLERATE_TESTS "Enable to generate test targets" ${LIBSAMPLERATE_IS_ROOT_PROJECT})
11+option(LIBSAMPLERATE_EXAMPLES "Enable to generate examples" ${LIBSAMPLERATE_IS_ROOT_PROJECT})
12+option(LIBSAMPLERATE_INSTALL "Enable to add install directives" ${LIBSAMPLERATE_IS_ROOT_PROJECT})
613
7−set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
14+list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
815
916 include(TestBigEndian)
1017 include(CheckFunctionExists)
@@ -104,7 +111,7 @@ endif() · 93 unmodified lines
104111
105112 if(LIBSAMPLERATE_TESTS)
106113
107−enable_testing()
114+ enable_testing()
108115
109116 file(GLOB TEST_SRCS ${PROJECT_SOURCE_DIR}/tests/*_test.c)
110117
@@ -117,10 +124,12 @@ foreach(testSrc ${TEST_SRCS}) · 6 unmodified lines
117124 target_link_libraries(${testName} PUBLIC samplerate)
118125 if(FFTW_FOUND)
119126 target_link_libraries(${testName} PUBLIC ${FFTW_LIBRARY})
120− endif()
127+endif()
121128 add_test(NAME ${testName} COMMAND ${testName})
122129 endforeach(testSrc)
130+endif()
123131
132+if(LIBSAMPLERATE_EXAMPLES)
124133 set(EXAMPLE_SRCS
125134 ${PROJECT_SOURCE_DIR}/examples/timewarp-file.c
126135 ${PROJECT_SOURCE_DIR}/examples/varispeed-play.c)
@@ -147,19 +156,19 @@ endforeach(exampleSrc) · 20 unmodified lines
147156 endif()
148157
149158 if(LIBSAMPLERATE_INSTALL)
150−set(prefix ${CMAKE_INSTALL_PREFIX})
151−set(exec_prefix "\${prefix}")
152−set(includedir "\${prefix}/include")
153−set(libdir "\${exec_prefix}/lib")
154−set(VERSION "${PROJECT_VERSION}")
155−if(NEED_MATH)
156− set(LIBS "-lm")
157−endif()
158−configure_file(samplerate.pc.in samplerate.pc @ONLY)
159−
160−install(TARGETS samplerate DESTINATION lib)
161−install(FILES src/samplerate.h DESTINATION include)
162−install(DIRECTORY doc/ DESTINATION share/doc/libsamplerate)
163−install(FILES ${CMAKE_BINARY_DIR}/samplerate.pc DESTINATION lib/pkgconfig)
159+ set(prefix ${CMAKE_INSTALL_PREFIX})
160+ set(exec_prefix "\${prefix}")
161+ set(includedir "\${prefix}/include")
162+ set(libdir "\${exec_prefix}/lib")
163+ set(VERSION "${PROJECT_VERSION}")
164+ if(NEED_MATH)
165+ set(LIBS "-lm")
166+ endif()
167+ configure_file(samplerate.pc.in samplerate.pc @ONLY)
168+
169+ install(TARGETS samplerate DESTINATION lib)
170+ install(FILES src/samplerate.h DESTINATION include)
171+ install(DIRECTORY doc/ DESTINATION share/doc/libsamplerate)
172+ install(FILES ${CMAKE_BINARY_DIR}/samplerate.pc DESTINATION lib/pkgconfig)
164173
165174 endif()

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