AlexeyDmitriev / JHelper

GNU Lesser General Public License v3.0
119 stars 31 forks source link

How to integrate spcppl to Jhelper? #105

Closed emli closed 5 years ago

emli commented 5 years ago

I tried add as sub-module but can't add successfully.

AlexeyDmitriev commented 5 years ago

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.

AlexeyDmitriev commented 5 years ago

Note you have example of the simplest "library" in the example project

emli commented 5 years ago
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. 
emli commented 5 years ago
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.
AlexeyDmitriev commented 5 years ago

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

emli commented 5 years ago

Why did you suggest test? For me testrunner worked

Thank you so much for helping

AlexeyDmitriev commented 5 years ago

Yep, you are right. I'm glad that it helped

pnpnpnpn commented 4 years ago

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.

pnpnpnpn commented 4 years ago

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!