CMake Module Support
I was wondering if there would be interest in supporting the cmake module interface. That way if project wanted to use the library, they would only have to add this one as a submodule, then link with the proper target to get all the flags and such they needed. It would be the case of adding 2-3 lines to the root cmake file.
add_library(simdpp INTERFACE)
target_include_directories(simdpp "simdpp")
That would be about all that is needed and would make things easier on people using cmake trying to utilize the library.
I think it's a good idea, thanks. Currently, only compiling for multiple architectures at once is abstracted to simdpp_multiarch macro. If users just want to compile for single architecture, they're on their own to provide appropriate defines. There could be an interface library for each popular instruction set combination.
If you'd be willing, I can briefly implement it as purely a superficial thing, merely allowing people to easily include the headers needed. They would still have to use the macro, but that would simplify the interface of adding the library as a header-only dependency.
Sorry for the late reply. If you can make something like this work:
add_library(simdpp_avx2 INTERFACE)
target_include_directories(simdpp "simdpp")
That would be greatly appreciated.
The problem is that at the end of the day there will have to be sources generated and you have to add them to your target. A macro is the only way to do that so you have a variety of platforms supported. So having a platform specific target doesn't make much sense, as well as going against the idea of cross platform code. You can't compile targeting ARM if the project has avx2 enabled...
I experimented and gave it a try in this branch: https://github.com/eriksjolund/libsimdpp/tree/modernize_cmake_support There are some more information in this git commit message: https://github.com/eriksjolund/libsimdpp/commit/9b305f754d0b3bfb2bbfd1236a316a77c20fd562
$ cat ~/example/CMakeLists.txt
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
project(example VERSION 1.0 LANGUAGES CXX)
find_package(libsimdpp REQUIRED)
add_executable(example main.cc)
target_link_libraries(example
PRIVATE
libsimdpp::libsimdpp
libsimdpp::SIMDPP_ARCH_X86_AVX)
Assuming libsimdpp was built in the directory /tmp/libsimdpp_build and installed into the directory /tmp/libsimdpp_install, you could run either
$ cmake -DCMAKE_PREFIX_PATH=/tmp/libsimdpp_build -GNinja ~/example/ && ninja
or
$ cmake -DCMAKE_PREFIX_PATH=/tmp/libsimdpp_install -GNinja ~/example/ && ninja
All this is great and looks very well implemented - kudos - but I don't see how it solves the problems of the macro being needed to do multiple compilation units which it seems to indicate through the AVX etc. targets.
That all being said, Thank You! The more developers support this way of including projects, the cleaner and easier using CMake with your project becomes!