Skip to content

Commit

Permalink
Merge pull request #217 from czoido/fix_cmake_conan_example
Browse files Browse the repository at this point in the history
Fix example
  • Loading branch information
czoido authored May 18, 2020
2 parents 36100b4 + 08e5129 commit 4ea2603
Show file tree
Hide file tree
Showing 4 changed files with 328 additions and 321 deletions.
13 changes: 8 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 2.8)
project(conan_wrapper CXX)
cmake_minimum_required(VERSION 2.8.12)
project(FormatOutput)

add_definitions("-std=c++11")

# if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
# message(STATUS "Downloading conan.cmake from https://github.com/memsharded/cmake-conan")
Expand All @@ -9,10 +11,11 @@ project(conan_wrapper CXX)

# include(${CMAKE_BINARY_DIR}/conan.cmake)
include(conan.cmake)
conan_cmake_run(REQUIRES Hello/0.1@memsharded/testing
conan_cmake_run(REQUIRES fmt/6.1.2
BASIC_SETUP CMAKE_TARGETS
BUILD missing)


add_executable(main main.cpp)
target_link_libraries(main CONAN_PKG::Hello)
# target_link_libraries(main ${CONAN_LIBS})
target_link_libraries(main CONAN_PKG::fmt)
#target_link_libraries(main ${CONAN_LIBS})
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ You probably want to use a tagged release to ensure controlled upgrades.
You can just clone or grab the *conan.cmake* file and put in in your project.
Or it can be used in this way. Note the ``v0.15`` tag in the URL, change it to point to your desired release:


```cmake
cmake_minimum_required(VERSION 2.8)
project(myproject CXX)
project(FormatOutput CXX)
# Download automatically, you can also just copy the conan.cmake file
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
Expand All @@ -32,7 +31,7 @@ endif()
include(${CMAKE_BINARY_DIR}/conan.cmake)
conan_cmake_run(REQUIRES Hello/0.1@memsharded/testing
conan_cmake_run(REQUIRES fmt/6.1.2
BASIC_SETUP
BUILD missing)
Expand All @@ -45,8 +44,8 @@ target_link_libraries(main ${CONAN_LIBS})

### REQUIRES, OPTIONS
```cmake
conan_cmake_run(REQUIRES Hello/0.1@memsharded/testing
Bye/2.1@otheruser/testing
conan_cmake_run(REQUIRES fmt/1.9.4
cgal/5.0.2
OPTIONS Pkg:shared=True
OtherPkg:option=value
)
Expand All @@ -61,12 +60,12 @@ If you want to use targets, you could do:

```cmake
include(conan.cmake)
conan_cmake_run(REQUIRES Hello/0.1@memsharded/testing
conan_cmake_run(REQUIRES fmt/1.9.4
BASIC_SETUP CMAKE_TARGETS
BUILD missing)
add_executable(main main.cpp)
target_link_libraries(main CONAN_PKG::Hello)
target_link_libraries(main CONAN_PKG::fmt)
```

This will do a ``conan_basic_setup(TARGETS)`` for modern CMake targets definition.
Expand Down
38 changes: 4 additions & 34 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,36 +1,6 @@
#include "hello.h"
#include "fmt/color.h"

int main(){
hello();
int main() {
fmt::print(fg(fmt::terminal_color::cyan), "Hello!\n");
return 0;
}

/*#include "Poco/Timer.h"
#include "Poco/Thread.h"
#include "Poco/Stopwatch.h"
#include <iostream>
using Poco::Timer;
using Poco::TimerCallback;
using Poco::Thread;
using Poco::Stopwatch;
class TimerExample{
public:
TimerExample(){ _sw.start();}
void onTimer(Timer& timer){
std::cout << "Callback called after " << _sw.elapsed()/1000 << " milliseconds." << std::endl;
}
private:
Stopwatch _sw;
};
int main(int argc, char** argv){
TimerExample example;
Timer timer(250, 500);
timer.start(TimerCallback<TimerExample>(example, &TimerExample::onTimer));
Thread::sleep(1000);
timer.stop();
return 0;
}*/
Loading

0 comments on commit 4ea2603

Please sign in to comment.