berndporr / iir1

DSP IIR realtime filter library written in C++
http://berndporr.github.io/iir1/
MIT License
637 stars 140 forks source link

Add Support for CMake FetchContent #18

Closed epezent closed 3 years ago

epezent commented 3 years ago

This PR makes a small modification to CMakeLists.txt to enable the library to be used with the FetchContent feature, obviating the need to build and install separately:

include(FetchContent) 
FetchContent_Declare(iir GIT_REPOSITORY https://github.com/berndporr/iir1) 
FetchContent_MakeAvailable(iir)

add_executable(filter_toy "filter_toy.cpp")
target_link_libraries(filter_toy iir::iir_static)
berndporr commented 3 years ago

Thanks for the PR. I've just tried it out with a new CMakeLists for the demo (in a temp dir so that it won't know any deps). CMakeLists.txt Got a few error messages but created the makefile.

 Policy CMP0048 is not set: project() command manages VERSION variables.
  Run "cmake --help-policy CMP0048" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  The following variable(s) would be set to empty:

    CMAKE_PROJECT_VERSION
    CMAKE_PROJECT_VERSION_MAJOR
    CMAKE_PROJECT_VERSION_MINOR
    CMAKE_PROJECT_VERSION_PATCH
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at CMakeLists.txt:7 (add_executable):
  Policy CMP0002 is not set: Logical target names must be globally unique.
  Run "cmake --help-policy CMP0002" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at CMakeLists.txt:10 (add_executable):
  Policy CMP0002 is not set: Logical target names must be globally unique.
  Run "cmake --help-policy CMP0002" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) in CMakeLists.txt:
  No cmake_minimum_required command is present.  A line of code such as

    cmake_minimum_required(VERSION 3.16)

  should be added at the top of the file.  The version specified may be lower
  if you wish to support older CMake versions for this project.  For more
  information run "cmake --help-policy CMP0000".
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/demo

Are there any issues arising for 2.x? I have a few people who work with ancient cmake versions.

epezent commented 3 years ago

Are there any issues arising for 2.x? I have a few people who work with ancient cmake versions.

Thanks for merging! Support for FetchContent was added in 3.11, but the actual changes here (i.e. ALIAS and $<BUILD_INTERFACE:$...>) far precede that. I'm not completely sure how far back though.

berndporr commented 3 years ago

Indeed. These are all pretty generic commands. In don't think that will be a problem for people using 2.x. I just went through the previous pull requests and @thecaptury sent the pull request to make it work with 2.x. @thecaptury, could you test it on your old system?