Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [ 25%] Building CXX object say-hello/CMakeFiles/say-hello.dir/src/say-hello/hello.cpp.o
- <command-line>:0:14: warning: ISO C++11 requires whitespace after the macro name
- /home/maximilian/Dokumente/02_Programmieren/VSCMAKE/say-hello/src/say-hello/hello.cpp: In function ‘void hello::say()’:
- <command-line>:0:17: error: expected ‘;’ before numeric constant
- /home/maximilian/Dokumente/02_Programmieren/VSCMAKE/say-hello/src/say-hello/hello.cpp:7:43: note: in expansion of macro ‘HELLO_VERSION’
- std::cout << "Hello (Version " << HELLO_VERSION << ")n";
- ^~~~~~~~~~~~~
- say-hello/CMakeFiles/say-hello.dir/build.make:62: recipe for target 'say-hello/CMakeFiles/say-hello.dir/src/say-hello/hello.cpp.o' failed
- make[2]: *** [say-hello/CMakeFiles/say-hello.dir/src/say-hello/hello.cpp.o] Error 1
- CMakeFiles/Makefile2:90: recipe for target 'say-hello/CMakeFiles/say-hello.dir/all' failed
- make[1]: *** [say-hello/CMakeFiles/say-hello.dir/all] Error 2
- Makefile:83: recipe for target 'all' failed
- make: *** [all] Error 2
- cmake_minimum_required(VERSION 3.14.4)
- project(MyProject VERSION 1.0.0)
- set(CMAKE_CXX_STANDARD 11)
- add_subdirectory(say-hello)
- add_subdirectory(mainsrc)
- add_executable(main.out main.cpp)
- target_link_libraries(main.out PRIVATE say-hello)
- #include <iostream>
- #include <say-hello/hello.hpp>
- int main(){
- hello::say();
- return 0;
- }
- add_library(say-hello
- src/say-hello/hello.cpp
- src/say-hello/hello.hpp
- )
- target_include_directories(say-hello PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src")
- target_compile_definitions(say-hello PUBLIC HELLO_VERSION-4)
- #ifndef HELLO
- #define HELLO
- //#define SAYHELLOVERSION 4
- namespace hello{
- void say();
- }
- #endif
- #include <iostream>
- #include "hello.hpp"
- namespace hello{
- void say(){
- //int version = SAYHELLOVERSION;
- std::cout << "Hello (Version " << HELLO_VERSION << ")n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement