From ddf492f8dabdb2f3f4bab30522a3cb40f4f6f7b1 Mon Sep 17 00:00:00 2001 From: thinking Date: Mon, 12 Mar 2018 04:23:50 +0800 Subject: [PATCH] CMakelist add debug --- CMakeLists.txt | 13 +++- adapterjs/CMakeLists.txt | 10 ++- adapterjs/adapterjavascriptimpl.cpp | 5 -- adapterlua/CMakeLists.txt | 10 ++- adapterpy/CMakeLists.txt | 9 +++ adapters/CMakeLists.txt | 7 +++ asynio/CMakeLists.txt | 9 ++- comenv/CMakeLists.txt | 10 ++- include/dlcom/tproperty.h | 2 +- infoanalysis/CMakeLists.txt | 10 ++- infoanalysis/json.cpp | 98 +---------------------------- main/CMakeLists.txt | 12 +++- mempool/CMakeLists.txt | 8 +++ sshchannel/CMakeLists.txt | 10 +-- sshchannel/sshchannelimpl.cpp | 3 + 15 files changed, 99 insertions(+), 117 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d557b3a..58d999e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,18 @@ project(mainapp) +cmake_minimum_required(VERSION 2.8) + if(CMAKE_BUILD_TYPE STREQUAL Release) set(CMAKE_BUILD_TYPE Release) + message("Release Compile Project") + set(by3rd_library_output "${PROJECT_SOURCE_DIR}/3rd/lib" CACHE INTERNAL "3rd Library" ) set(by3rd_library_execute "${PROJECT_SOURCE_DIR}/3rdexecute/release" CACHE INTERNAL "3rd execute" ) else() - set(CMAKE_BUILD_TYPE debug) + set(CMAKE_BUILD_TYPE Debug) add_definitions(-DDEBUG) + message("Debug Compile Project") + set(by3rd_library_output "${PROJECT_SOURCE_DIR}/3rd/lib" CACHE INTERNAL "3rd Library" ) set(by3rd_library_execute "${PROJECT_SOURCE_DIR}/3rd/3rdexecute/debug" CACHE INTERNAL "3rd execute" ) endif() @@ -31,6 +37,8 @@ else() endif() +message("Compile Info") +message("Compile System = ${CMAKE_SYSTEM_NAME}") add_subdirectory(main) add_subdirectory(comenv) add_subdirectory(infoanalysis) @@ -40,5 +48,4 @@ add_subdirectory(sshchannel) #add_subdirectory(adapterlua) #add_subdirectory(adapterpy) #add_subdirectory(mempool) -#add_subdirectory(adapters) - +#add_subdirectory(adapters) \ No newline at end of file diff --git a/adapterjs/CMakeLists.txt b/adapterjs/CMakeLists.txt index 2a69fc8b..b38f0d48 100644 --- a/adapterjs/CMakeLists.txt +++ b/adapterjs/CMakeLists.txt @@ -17,9 +17,15 @@ add_library(adapterjs SHARED ${adapterjs_src}) set_target_properties(adapterjs PROPERTIES OUTPUT_NAME "adapterjs") set_target_properties(adapterjs PROPERTIES COMPILE_FLAGS "-fvisibility=hidden -std=c++11 -fpermissive -fPIC -frtti -fexceptions") -target_link_libraries(adapterjs dl pthread) +if(CMAKE_BUILD_TYPE STREQUAL Debug) + set_target_properties(adapterjs PROPERTIES COMPILE_FLAGS "-g3") +endif() + +if(CMAKE_BUILD_TYPE STREQUAL Release) + set_target_properties(adapterjs PROPERTIES COMPILE_FLAGS "-O3") +endif() -target_link_libraries(adapterjs libnode.a) +target_link_libraries(adapterjs dl pthread) install(TARGETS adapterjs LIBRARY DESTINATION bin diff --git a/adapterjs/adapterjavascriptimpl.cpp b/adapterjs/adapterjavascriptimpl.cpp index 76b5bb77..aa8cb2d2 100644 --- a/adapterjs/adapterjavascriptimpl.cpp +++ b/adapterjs/adapterjavascriptimpl.cpp @@ -1,7 +1,4 @@ #include "adapterjavascriptimpl.h" -#include -using namespace node; - CAdapterjavascriptImpl::CAdapterjavascriptImpl(void) { } @@ -50,8 +47,6 @@ std_method_impl CAdapterjavascriptImpl::RunFile(const char* file) char** argv = new char*[argc + 1]; string_strcpy(argv[0],"-e"); string_strcpy(argv[1],"console.log('Hello World')"); - - node::Start(argc, argv); return hr; } \ No newline at end of file diff --git a/adapterlua/CMakeLists.txt b/adapterlua/CMakeLists.txt index 53e104c0..4dedb403 100644 --- a/adapterlua/CMakeLists.txt +++ b/adapterlua/CMakeLists.txt @@ -24,7 +24,15 @@ add_library(adapterlua SHARED ${adapterlua_src}) set_target_properties(adapterlua PROPERTIES OUTPUT_NAME "adapterlua") set_target_properties(adapterlua PROPERTIES COMPILE_FLAGS "-fvisibility=hidden -std=c++11 -fpermissive -fPIC -frtti -fexceptions") -#link_directories(/usr/lib/x86_64-linux-gnu) + +if(CMAKE_BUILD_TYPE STREQUAL Debug) + set_target_properties(adapterlua PROPERTIES COMPILE_FLAGS "-g3") +endif() + +if(CMAKE_BUILD_TYPE STREQUAL Release) + set_target_properties(adapterlua PROPERTIES COMPILE_FLAGS "-O3") +endif() + target_link_libraries(adapterlua dl crypt m lua5.1) diff --git a/adapterpy/CMakeLists.txt b/adapterpy/CMakeLists.txt index 95f51a42..da5dfd3c 100644 --- a/adapterpy/CMakeLists.txt +++ b/adapterpy/CMakeLists.txt @@ -25,6 +25,15 @@ add_library(adapterpy SHARED ${adapterpy_src}) set_target_properties(adapterpy PROPERTIES OUTPUT_NAME "adapterpy") set_target_properties(adapterpy PROPERTIES COMPILE_FLAGS "-fvisibility=hidden -std=c++11 -fpermissive -fPIC -frtti -fexceptions") +if(CMAKE_BUILD_TYPE STREQUAL Debug) + set_target_properties(adapterpy PROPERTIES COMPILE_FLAGS "-g3") +endif() + +if(CMAKE_BUILD_TYPE STREQUAL Release) + set_target_properties(adapterpy PROPERTIES COMPILE_FLAGS "-O3") +endif() + + link_directories(/usr/lib/x86_64-linux-gnu) target_link_libraries(adapterpy dl crypt m libpython3.4m.so) diff --git a/adapters/CMakeLists.txt b/adapters/CMakeLists.txt index 11a63063..85dcacd4 100644 --- a/adapters/CMakeLists.txt +++ b/adapters/CMakeLists.txt @@ -24,6 +24,13 @@ add_library(adapters SHARED ${adapters_src}) set_target_properties(adapters PROPERTIES OUTPUT_NAME "adapters") set_target_properties(adapters PROPERTIES COMPILE_FLAGS "-fvisibility=hidden -std=c++11 -fpermissive -fPIC -frtti -fexceptions") +if(CMAKE_BUILD_TYPE STREQUAL Debug) + set_target_properties(adapters PROPERTIES COMPILE_FLAGS "-g3") +endif() + +if(CMAKE_BUILD_TYPE STREQUAL Release) + set_target_properties(adapters PROPERTIES COMPILE_FLAGS "-O3") +endif() target_link_libraries(adapters dl crypt m lua5.1) diff --git a/asynio/CMakeLists.txt b/asynio/CMakeLists.txt index 90ef4735..2e36f0bb 100644 --- a/asynio/CMakeLists.txt +++ b/asynio/CMakeLists.txt @@ -31,7 +31,14 @@ set_target_properties(asynio PROPERTIES OUTPUT_NAME "asynio") set_target_properties(asynio PROPERTIES COMPILE_FLAGS "-fvisibility=hidden -fPIC -std=c++11 -frtti -Wall -Werror -fexceptions") -#target_compile_options(asynio PRIVATE -fvisibility=hidden -fPIC -std=c++11 -frtti -Wall -fexceptions) +if(CMAKE_BUILD_TYPE STREQUAL Debug) + set_target_properties(asynio PROPERTIES COMPILE_FLAGS "-g3") +endif() + +if(CMAKE_BUILD_TYPE STREQUAL Release) + set_target_properties(asynio PROPERTIES COMPILE_FLAGS "-O3") +endif() + target_link_libraries(asynio dl) diff --git a/comenv/CMakeLists.txt b/comenv/CMakeLists.txt index 8e7fe308..a83a5ba2 100644 --- a/comenv/CMakeLists.txt +++ b/comenv/CMakeLists.txt @@ -31,7 +31,15 @@ set_target_properties(comenv PROPERTIES OUTPUT_NAME "comenv") set_target_properties(comenv PROPERTIES COMPILE_FLAGS "-fvisibility=hidden -fPIC -std=c++11 -frtti -Wall -Werror -fexceptions") -#target_compile_options(comenv PRIVATE -fvisibility=hidden -fPIC -std=c++11 -frtti -Wall -fexceptions) + +if(CMAKE_BUILD_TYPE STREQUAL Debug) + set_target_properties(comenv PROPERTIES COMPILE_FLAGS "-g3") +endif() + +if(CMAKE_BUILD_TYPE STREQUAL Release) + set_target_properties(comenv PROPERTIES COMPILE_FLAGS "-O3") +endif() + target_link_libraries(comenv dl) diff --git a/include/dlcom/tproperty.h b/include/dlcom/tproperty.h index 34da5b27..8e73a719 100644 --- a/include/dlcom/tproperty.h +++ b/include/dlcom/tproperty.h @@ -7,7 +7,7 @@ using namespace util; namespace by { - template> + template > class TProperty_Impl { public: diff --git a/infoanalysis/CMakeLists.txt b/infoanalysis/CMakeLists.txt index 633755ab..8a25f7ef 100644 --- a/infoanalysis/CMakeLists.txt +++ b/infoanalysis/CMakeLists.txt @@ -30,7 +30,15 @@ set_target_properties(infoanalysis PROPERTIES OUTPUT_NAME "infoanalysis") set_target_properties(infoanalysis PROPERTIES COMPILE_FLAGS "-fvisibility=hidden -fPIC -std=c++11 -frtti -Wall -Werror -fexceptions") -#target_compile_options(infoanalysis PRIVATE -fvisibility=hidden -fPIC -std=c++11 -frtti -Wall -fexceptions) + +if(CMAKE_BUILD_TYPE STREQUAL Debug) + set_target_properties(infoanalysis PROPERTIES COMPILE_FLAGS "-g3") +endif() + +if(CMAKE_BUILD_TYPE STREQUAL Release) + set_target_properties(infoanalysis PROPERTIES COMPILE_FLAGS "-O3") +endif() + target_link_libraries(infoanalysis dl) diff --git a/infoanalysis/json.cpp b/infoanalysis/json.cpp index b6771e34..5e6b2210 100644 --- a/infoanalysis/json.cpp +++ b/infoanalysis/json.cpp @@ -31,106 +31,12 @@ string& CJson::replace_all(string& str, const string& old_value, const string& string CJson::Json2Xml(const string &strJson) { - string strXml = ""; - cJSON *pRoot = cJSON_Parse(strJson.c_str()); - if (NULL == pRoot) - { - return ""; - } - cJSON *pChild = pRoot->child; - while (pChild != NULL) - { - if (pChild->child != NULL) - { - std::string strSubKey = pChild->string; - - std::string strSubValue = Json2Xml(cJSON_Print(pChild)); - std::string strSubXml = "<" + strSubKey + ">" + strSubValue + ""; - strXml += strSubXml; - }else - { - std::string strKey = pChild->string; - std::string strVal = ""; - if (pChild->valuestring != NULL) - { - string strTemp = pChild->valuestring; - strVal = "\"" + strTemp + "\""; - }else - { - strVal = cJSON_Print(pChild); - } - - strXml = strXml + "<" + strKey + ">" + strVal + ""; - - } - - pChild = pChild->next; - } - if(NULL != pRoot) - { - cJSON_Delete(pRoot); - } - - return strXml; + return ""; } string CJson::Xml2Json(const string &strxml) { - cJSON *pJsonRoot = cJSON_CreateObject(); - - string strNext = strxml; - int nPos = 0; - while ((nPos = strNext.find("<")) != -1) - { - string strKey = GetXmlKey(strNext); - string strValue = GetXmlValueFromKey(strNext, strKey); - string strCurrXml = strNext; - strNext = GoToNextItem(strNext, strKey); - int LabelPos = strValue.find("<"); - int nMarkPos = strValue.find("\""); - if (strValue != "" && LabelPos != -1 && LabelPos < nMarkPos) - { - string strNextKey = GetXmlKey(strNext); - if (strNextKey == strKey) - { - cJSON *pArrayObj = cJSON_CreateArray(); - int nCnt = GetArrayItem(strCurrXml); - for (int i = 0; i < nCnt; i++) - { - strKey = GetXmlKey(strCurrXml); - strValue = GetXmlValueFromKey(strCurrXml, strKey); - string strArrayItem = Xml2Json(strValue); - cJSON *pArrayItem = cJSON_Parse(strArrayItem.c_str()); - cJSON_AddItemToArray(pArrayObj, pArrayItem); - strCurrXml = GoToNextItem(strCurrXml, strKey); - } - - cJSON_AddItemToObject(pJsonRoot, strNextKey.c_str(), pArrayObj); - strNext = strCurrXml; - }else - { - string strSubJson = Xml2Json(strValue); - cJSON *pSubJsonItem = cJSON_CreateObject(); - pSubJsonItem = cJSON_Parse(strSubJson.c_str()); - cJSON_AddItemToObject(pJsonRoot, strKey.c_str(), pSubJsonItem); - } - } - else - { - if (strValue.find("\"") == string::npos) - { - cJSON_AddNumberToObject(pJsonRoot, strKey.c_str(), atof(strValue.c_str())); - }else - { - remove_char(strValue, '\"'); - cJSON_AddStringToObject(pJsonRoot, strKey.c_str(), strValue.c_str()); - } - } - } - - string strJson = cJSON_Print(pJsonRoot); - cJSON_Delete(pJsonRoot); - return strJson; + return ""; } string CJson::GetXmlKey(const string &strxml) diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index de084100..f2769353 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -25,10 +25,18 @@ set_target_properties(main PROPERTIES OUTPUT_NAME "main") set_target_properties(main PROPERTIES COMPILE_FLAGS "-std=c++11 -Wall -Werror -fexceptions") -link_directories (/usr/local/lib) +if(CMAKE_BUILD_TYPE STREQUAL Debug) + set_target_properties(main PROPERTIES COMPILE_FLAGS "-g3") +endif() -target_link_libraries(main dl) +if(CMAKE_BUILD_TYPE STREQUAL Release) + set_target_properties(main PROPERTIES COMPILE_FLAGS "-O3") +endif() + + +link_directories (/usr/local/lib) +target_link_libraries(main dl) install(TARGETS main DESTINATION bin) diff --git a/mempool/CMakeLists.txt b/mempool/CMakeLists.txt index 07cd7ec6..b7fc3cb2 100644 --- a/mempool/CMakeLists.txt +++ b/mempool/CMakeLists.txt @@ -28,6 +28,14 @@ set_target_properties(mempool PROPERTIES OUTPUT_NAME "mempool") set_target_properties(mempool PROPERTIES COMPILE_FLAGS "-fvisibility=hidden -std=c++11 -fpermissive -fPIC -frtti -fexceptions") +if(CMAKE_BUILD_TYPE STREQUAL Debug) + set_target_properties(mempool PROPERTIES COMPILE_FLAGS "-g3") +endif() + +if(CMAKE_BUILD_TYPE STREQUAL Release) + set_target_properties(mempool PROPERTIES COMPILE_FLAGS "-O3") +endif() + target_link_libraries(mempool dl crypt) install(TARGETS mempool diff --git a/sshchannel/CMakeLists.txt b/sshchannel/CMakeLists.txt index 2f332ac3..58e7419f 100644 --- a/sshchannel/CMakeLists.txt +++ b/sshchannel/CMakeLists.txt @@ -30,11 +30,13 @@ set_target_properties(sshchannel PROPERTIES OUTPUT_NAME "sshchannel") set_target_properties(sshchannel PROPERTIES COMPILE_FLAGS "-fvisibility=hidden -std=c++11 -fpermissive -fPIC -frtti -fexceptions") +if(CMAKE_BUILD_TYPE STREQUAL Debug) + set_target_properties(sshchannel PROPERTIES COMPILE_FLAGS "-g3") +endif() - - - - +if(CMAKE_BUILD_TYPE STREQUAL Release) + set_target_properties(sshchannel PROPERTIES COMPILE_FLAGS "-O3") +endif() install(TARGETS sshchannel diff --git a/sshchannel/sshchannelimpl.cpp b/sshchannel/sshchannelimpl.cpp index c2cb35c6..5c4dcd40 100644 --- a/sshchannel/sshchannelimpl.cpp +++ b/sshchannel/sshchannelimpl.cpp @@ -43,6 +43,9 @@ std_method_impl CSshChannelImpl::Start() std_method_impl CSshChannelImpl::Stop() { HRESULT hr = S_OK; + + WaitDebug(); + return hr; } -- Gitee