How to integrate spcppl to Jhelper?
Closed this issue · 9 comments
I tried add as sub-module but can't add successfully.
You just put it as a directory to your project and it in CMake and link to a library:
add_subdirectory(name_of_the_directory)
target_link_libraries(test spcppl)
Note that linking doesn't change much practically because it's a header-only library but still.
Note you have example of the simplest "library" in the example project
cmake_minimum_required(VERSION 3.1)
project(emli-competitive-programming)
add_executable(testrunner testrunner/main.cpp)
file(GLOB TASKS "tasks/*.cpp")
file(GLOB_RECURSE HEADERS "lib/*.hpp")
ADD_DEFINITIONS(-std=c++11)
add_executable(test ${TASKS} ${HEADERS})
#include "../lib/spcppl/numbers/primes.hpp"
class Test {
public:
void solve(std::istream &cin, std::ostream &cout) {
isPrime(0);
}
};
from /home/jedi/Desktop/competitive/testrunner/main.cpp:1:
/home/jedi/Desktop/competitive/tasks/../lib/spcppl/numbers/primes.hpp:5:34: fatal error: spcppl/ranges/fors.hpp: No such file or directory```
Don't know how to fix.
project(emli-competitive-programming)
add_executable(testrunner testrunner/main.cpp)
file(GLOB TASKS "tasks/*.cpp")
file(GLOB_RECURSE HEADERS "lib/*.hpp")
add_subdirectory(lib)
target_link_libraries(lib spcppl)
ADD_DEFINITIONS(-std=c++11)
add_executable(test ${TASKS} ${HEADERS})
Also tried this method too.
This gives
Cannot specify link libraries for target "lib" which is not built by this
project.
It should be target_link_libraries(test spcppl)
(and after you added test executable). After that you should be able to include <spcppl/numbers/primes.hpp>
. At least if I understood structure of your directories correctly
Why did you suggest test? For me testrunner worked
Thank you so much for helping
Yep, you are right. I'm glad that it helped
Could either of you please clarify what the final solution was? I am trying to do this exact thing, and have read through this thread about 10 times now, yet I still can't make it work on my end :(
Thanks in advance.
For instance Alexey would it be possible for you to add the actual CLion project that you use for contests to Github? I know there is the example project, which is what I used, however it does not have spcppl and I can't seem to add it. If there is no confidential data in your project, it would be so awesome to just start with your exact environment, which already contains spcppl and is fully set up.
Thanks so much!