cmake_minimum_required(VERSION 2.8.12) project(guttersynth) # User options option(USE_FLOAT "Set to use single-precision floating point." OFF) option(CREATE_STATIC "Set to create the static library in addition to shared library." ON) option(BUILD_EXAMPLES "Set to build the example programs." ON) set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") if(USE_FLOAT) message(STATUS "Building with 32-bit floats") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_FLOAT") else() message(STATUS "Building with 64-bit floats") endif() include_directories("include") set(CSOURCES "src/guttersynth.c") set(PUBLIC_HEADERS "include/guttersynth.h" "include/guttersynth.hpp") add_library(guttersynth SHARED ${CSOURCES}) target_link_libraries(guttersynth m) set_target_properties(guttersynth PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}") install(TARGETS guttersynth ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin PUBLIC_HEADER DESTINATION include) if (CREATE_STATIC) add_library(guttersynthstatic STATIC ${CSOURCES}) target_link_libraries(guttersynthstatic m) install(TARGETS guttersynthstatic ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin) endif() if (BUILD_EXAMPLES) add_executable(guttersynthexample1 "examples/example1.c") target_link_libraries(guttersynthexample1 LINK_PUBLIC guttersynth) add_executable(guttersynthexample2 "examples/example2.cpp") target_link_libraries(guttersynthexample2 LINK_PUBLIC guttersynth) find_package(Portaudio) if (PORTAUDIO_FOUND) message(STATUS "Portaudio found, example 3 building") add_executable(guttersynthexample3 "examples/example3.c") target_include_directories(guttersynthexample3 PUBLIC ${PORTAUDIO_INCLUDE_DIRS}) target_link_libraries(guttersynthexample3 LINK_PUBLIC ${PORTAUDIO_LIBRARIES}) target_link_libraries(guttersynthexample3 LINK_PUBLIC guttersynth) else() message(STATUS "Portaudio not found, example 3 not building") endif() endif()