Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CMake 0.62 KB | None | 0 0
  1. cmake_minimum_required(VERSION 3.4)
  2.  
  3. project(Foo)
  4.  
  5. include(GenerateExportHeader)
  6.  
  7. file(WRITE foo.hpp [[
  8.     #include "foo_export.h"
  9.  
  10.     class FOO_EXPORT Foo
  11.     {
  12.     public:
  13.         Foo() {}
  14.  
  15.         static void my_static();
  16.     };
  17. ]])
  18.  
  19. file(WRITE foo.cpp [[
  20.     #include "foo.hpp"
  21.  
  22.     void Foo::my_static()
  23.     {
  24.  
  25.     }
  26. ]])
  27.  
  28. add_library(foo SHARED foo.cpp foo.hpp)
  29. target_include_directories(foo PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
  30.  
  31. generate_export_header(foo)
  32.  
  33. file(WRITE bar.cpp [[
  34.     #include "foo.hpp"
  35.  
  36.     int main()
  37.     {
  38.         Foo::my_static();
  39.  
  40.         Foo foo;
  41.     }
  42. ]])
  43.  
  44. add_executable(bar bar.cpp)
  45. target_link_libraries(bar PRIVATE foo)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement