C++ベースのLightweightなHTTPサーバー
| Revision | 413aa1297e01ff71d29ac47319dad485c2139acf (tree) |
|---|---|
| Time | 2013-03-17 13:51:41 |
| Author | Michio Hirai <smg_ykz@user...> |
| Commiter | Michio Hirai |
[Function] Addition of PROCESS macro in conjunction with cm_main library introduction.
1:
| @@ -40,6 +40,20 @@ function(cxx_library_static libname link_libs) | ||
| 40 | 40 | set_property(DIRECTORY APPEND PROPERTY DIR_LIB_TARGETS "${libname}") |
| 41 | 41 | endfunction(cxx_library_static) |
| 42 | 42 | |
| 43 | +# function cxx_executable(<executable_name> "lib1;lib2;..." | |
| 44 | +# followed by source files" | |
| 45 | +function(cxx_executable exename link_libs) | |
| 46 | + add_executable(${exename} ${ARGN}) | |
| 47 | + target_link_libraries(${exename} "cm_main") | |
| 48 | + target_link_libraries(${exename} "stdc++") | |
| 49 | + foreach(li ${link_libs}) | |
| 50 | + target_link_libraries(${exename} ${li}) | |
| 51 | + endforeach(li) | |
| 52 | + set_property(DIRECTORY APPEND PROPERTY DIR_TEST_TARGETS "${exename}") | |
| 53 | + add_test(${exename} ${CMAKE_CURRENT_BINARY_DIR}/${exename}) | |
| 54 | +endfunction(cxx_executable) | |
| 55 | + | |
| 56 | + | |
| 43 | 57 | # function gmock_executable(<executable_name> "lib1;lib2;..." |
| 44 | 58 | # followed by source files) |
| 45 | 59 | function(gmock_executable exename link_libs) |
| @@ -25,6 +25,10 @@ cxx_library_static(cm_socket "" | ||
| 25 | 25 | cm_vector_socket.cpp |
| 26 | 26 | ) |
| 27 | 27 | |
| 28 | +cxx_library_static(cm_main "" | |
| 29 | + cm_main.cpp | |
| 30 | +) | |
| 31 | + | |
| 28 | 32 | gmock_executable(cm_thread_test "cm_thread" |
| 29 | 33 | test/cm_thread_test.cpp |
| 30 | 34 | test/cm_mutex_test.cpp |
| @@ -43,5 +47,9 @@ gmock_executable(cm_vector_socket_test "cm_socket;" | ||
| 43 | 47 | test/cm_vector_socket_test.cpp |
| 44 | 48 | ) |
| 45 | 49 | |
| 50 | +cxx_executable(cm_main_test "" | |
| 51 | + test/cm_main_sample.cpp | |
| 52 | +) | |
| 53 | + | |
| 46 | 54 | enable_coverage() |
| 47 | 55 |
| @@ -0,0 +1,14 @@ | ||
| 1 | + | |
| 2 | +#include "cm_process.h" | |
| 3 | +#include "cm_thread_name_macro.h" | |
| 4 | + | |
| 5 | +const char* getProcessName(); | |
| 6 | + | |
| 7 | +int doProcess(int argc, char *argv[]); | |
| 8 | + | |
| 9 | +int main(int argc, char *argv[]) | |
| 10 | +{ | |
| 11 | + SETNAME(gettid(), getProcessName()); | |
| 12 | + return doProcess(argc, argv); | |
| 13 | +} | |
| 14 | + |
| @@ -0,0 +1,13 @@ | ||
| 1 | + | |
| 2 | +#include <iostream> | |
| 3 | + | |
| 4 | +#include "cm_process.h" | |
| 5 | +#include "mt_unuse.h" | |
| 6 | + | |
| 7 | +PROCESS(hello_sample) | |
| 8 | +{ | |
| 9 | + mt::unuse(argc); | |
| 10 | + mt::unuse(argv); | |
| 11 | + std::cout << "Hello World!!" << std::endl; | |
| 12 | +} | |
| 13 | + |
| @@ -0,0 +1,14 @@ | ||
| 1 | + | |
| 2 | +#ifndef INC_CM_PROCESS_H_ | |
| 3 | +#define INC_CM_PROCESS_H_ | |
| 4 | + | |
| 5 | +#include "cm_thread_name_macro.h" | |
| 6 | + | |
| 7 | +#define PROCESS(procname) \ | |
| 8 | +const char* getProcessName() \ | |
| 9 | +{ \ | |
| 10 | + return "#procname" ; \ | |
| 11 | +} \ | |
| 12 | +int doProcess(int argc, char *argv[]) | |
| 13 | + | |
| 14 | +#endif // INC_CM_PROCESS_H_ |