From 598e2fafded42455108a33976eb6b03eaadf33ed Mon Sep 17 00:00:00 2001 From: Sirius Bakke Date: Sat, 27 Jul 2019 17:30:21 +0200 Subject: [PATCH] refactor: Reduce cmake global defines --- CMakeLists.txt | 19 ++++++------------- doc/CMakeLists.txt | 4 +--- src/antlr/CMakeLists.txt | 2 -- src/cisco_lib/CMakeLists.txt | 2 -- src/common/CMakeLists.txt | 4 ++-- src/common/init.cpp | 4 ++-- src/compiler_lib/CMakeLists.txt | 2 -- .../CompilerDriver_generators.cpp | 1 + src/fwbedit/CMakeLists.txt | 4 ++-- src/fwbedit/fwbedit.cpp | 1 + src/gui/CMakeLists.txt | 2 -- src/gui/main.cpp | 1 + src/import/CMakeLists.txt | 2 -- src/iosacl/CMakeLists.txt | 4 ++-- src/iosacl/iosacl.cpp | 1 + src/ipf/CMakeLists.txt | 4 ++-- src/ipf/ipf.cpp | 1 + src/ipfw/CMakeLists.txt | 4 ++-- src/ipfw/ipfw.cpp | 1 + src/ipt/CMakeLists.txt | 4 ++-- src/ipt/ipt.cpp | 1 + src/iptlib/CMakeLists.txt | 2 -- src/iptlib/CompilerDriver_ipt_run.cpp | 1 + src/juniper_lib/CMakeLists.txt | 2 -- src/junosacl/CMakeLists.txt | 4 ++-- src/junosacl/junosacl.cpp | 1 + src/libfwbuilder/etc/CMakeLists.txt | 1 - src/libfwbuilder/migration/CMakeLists.txt | 3 +-- src/libfwbuilder/src/fwbuilder/CMakeLists.txt | 12 ++++++++++-- src/libfwbuilder/src/fwbuilder/Constants.cpp | 11 ++++++----- .../src/fwbuilder/FWObjectDatabase.cpp | 1 + src/libfwbuilder/src/fwbuilder/Resources.cpp | 8 ++++---- src/libfwbuilder/src/fwbuilder/Tools.cpp | 8 ++++---- src/libfwbuilder/src/fwbuilder/XMLTools.cpp | 8 +++++--- src/libfwbuilder/src/fwbuilder/XMLTools.h | 6 +++--- .../src/fwcompiler/CMakeLists.txt | 2 -- src/libgui/CMakeLists.txt | 2 -- src/libgui/CustomServiceDialog.cpp | 1 + src/libgui/FWBAboutDialog.cpp | 3 ++- src/libgui/FWBSettings.cpp | 6 ++++++ src/libgui/FWBSettings.h | 7 +------ src/libgui/FWBSettings_config.h | 8 ++++++++ src/libgui/FWWindow.cpp | 1 + src/libgui/FilterDialog.cpp | 1 + src/libgui/FindObjectWidget.cpp | 1 + src/libgui/RCS.cpp | 3 --- src/libgui/StartTipDialog.cpp | 1 + src/libgui/debugDialog.cpp | 2 +- src/libgui/instDialog_ui_ops.cpp | 1 + src/libgui/utils_no_qt.cpp | 2 +- src/nxosacl/CMakeLists.txt | 4 ++-- src/nxosacl/nxosacl.cpp | 1 + src/parsers/CMakeLists.txt | 2 -- src/pf/CMakeLists.txt | 4 ++-- src/pf/pf.cpp | 1 + src/pflib/CMakeLists.txt | 2 -- src/pix/CMakeLists.txt | 4 ++-- src/pix/pix.cpp | 1 + src/procurve_acl/CMakeLists.txt | 4 ++-- src/procurve_acl/procurve_acl.cpp | 1 + src/res/CMakeLists.txt | 7 +++---- src/version.h.in | 9 +++++++++ 62 files changed, 115 insertions(+), 102 deletions(-) create mode 100644 src/libgui/FWBSettings_config.h create mode 100644 src/version.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 636f21f5a..656029cd2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,13 @@ set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" project(firewallbuilder LANGUAGES CXX C) +### Version variables and include file + include(VERSION) +configure_file("${CMAKE_SOURCE_DIR}/src/version.h.in" "${CMAKE_BINARY_DIR}/src/version.h" @ONLY) +include_directories(${CMAKE_BINARY_DIR}/src) + +### Build type if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release CACHE STRING @@ -38,19 +44,6 @@ set(CXX_DEFAULT_FLAGS # clang/GCC warnings $<$:/WX;/W4>) add_definitions(-D__STDC_FORMAT_MACROS) -add_definitions(-DGENERATION="${PROJECT_GENERATION}") -add_definitions(-DVERSION="${PROJECT_VERSION}") -add_definitions(-DFS_SEPARATOR="/") -add_definitions(-DFWBUILDER_XML_VERSION="${FWBUILDER_XML_VERSION}") -add_definitions(-DPREFIX="${CMAKE_INSTALL_PREFIX}") - -if(APPLE) - add_definitions(-DRES_DIR="../Resources") -elseif(WIN32) - add_definitions(-DRES_DIR="resources") -else() - add_definitions(-DRES_DIR="${CMAKE_INSTALL_PREFIX}/${FWB_INSTALL_DATADIR}") -endif() if(WIN32) #add_definitions(-DIN_LIBXML) # Enable for static build diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 3e326e5e9..5c3d28275 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -1,6 +1,4 @@ -project(doc) - -FILE(GLOB readme_files "${PROJECT_SOURCE_DIR}/README.*") +FILE(GLOB readme_files "${CMAKE_CURRENT_SOURCE_DIR}/README.*") install(FILES AUTHORS diff --git a/src/antlr/CMakeLists.txt b/src/antlr/CMakeLists.txt index c1822c562..a6f136932 100644 --- a/src/antlr/CMakeLists.txt +++ b/src/antlr/CMakeLists.txt @@ -1,5 +1,3 @@ -project(antlr) - set(antlr_srcs ANTLRUtil.cpp ASTFactory.cpp diff --git a/src/cisco_lib/CMakeLists.txt b/src/cisco_lib/CMakeLists.txt index 4a4d27199..69fbe6f6b 100644 --- a/src/cisco_lib/CMakeLists.txt +++ b/src/cisco_lib/CMakeLists.txt @@ -1,5 +1,3 @@ -project(cisco_lib) - set(cisco_lib_srcs PolicyCompiler_cisco.cpp PolicyCompiler_cisco_acls.cpp diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 35432609e..3098daf36 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -1,5 +1,3 @@ -project(common) - set(common_srcs init.cpp init2.cpp) @@ -13,5 +11,7 @@ target_link_libraries(common fwbuilder) target_compile_options(common PRIVATE ${CXX_DEFAULT_FLAGS}) +set_source_files_properties(init.cpp PROPERTIES COMPILE_DEFINITIONS PREFIX=\"${CMAKE_INSTALL_PREFIX}\") + qt5_use_modules(common Core) diff --git a/src/common/init.cpp b/src/common/init.cpp index 1355748e0..b02e08e4e 100644 --- a/src/common/init.cpp +++ b/src/common/init.cpp @@ -44,14 +44,14 @@ using namespace libfwbuilder; void init(char * const*) { - appRootDir = string(PREFIX) + FS_SEPARATOR + "bin"; + appRootDir = string(PREFIX) + "/" + "bin"; /* On Unix RES_DIR and LIBFWBUILDER_TEMPLATE_DIR are absolute paths */ libfwbuilder::init(); /* need argv0 for built-in installer on unix and mac */ - argv0 = appRootDir + FS_SEPARATOR + "fwbuilder"; + argv0 = appRootDir + "/" + "fwbuilder"; /* default directory where the user may want to save files */ userDataDir = string(getenv("HOME")); diff --git a/src/compiler_lib/CMakeLists.txt b/src/compiler_lib/CMakeLists.txt index 9c8c5ef27..7a7656aa3 100644 --- a/src/compiler_lib/CMakeLists.txt +++ b/src/compiler_lib/CMakeLists.txt @@ -1,5 +1,3 @@ -project(compiler_lib) - set(compiler_lib_srcs CompilerDriver.cpp CompilerDriver_files.cpp diff --git a/src/compiler_lib/CompilerDriver_generators.cpp b/src/compiler_lib/CompilerDriver_generators.cpp index 4a75028f6..f55ffcfa1 100644 --- a/src/compiler_lib/CompilerDriver_generators.cpp +++ b/src/compiler_lib/CompilerDriver_generators.cpp @@ -28,6 +28,7 @@ #include #include +#include "version.h" #include "CompilerDriver.h" #include "Configlet.h" diff --git a/src/fwbedit/CMakeLists.txt b/src/fwbedit/CMakeLists.txt index e605965a6..748f1c2a9 100644 --- a/src/fwbedit/CMakeLists.txt +++ b/src/fwbedit/CMakeLists.txt @@ -1,5 +1,3 @@ -project(fwbedit) - find_package(OpenSSL REQUIRED) set(fwbedit_srcs @@ -30,6 +28,8 @@ ENDIF() target_compile_options(fwbedit PRIVATE ${CXX_DEFAULT_FLAGS}) +set_source_files_properties(fwbedit.cpp PROPERTIES COMPILE_DEFINITIONS PREFIX=\"${CMAKE_INSTALL_PREFIX}\") + install(TARGETS fwbedit RUNTIME DESTINATION ${FWB_INSTALL_BINDIR}) qt5_use_modules(fwbedit Widgets PrintSupport) diff --git a/src/fwbedit/fwbedit.cpp b/src/fwbedit/fwbedit.cpp index 0113740a5..48953ae38 100644 --- a/src/fwbedit/fwbedit.cpp +++ b/src/fwbedit/fwbedit.cpp @@ -22,6 +22,7 @@ */ +#include "version.h" #include "fwbuilder/Constants.h" #include diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index bc5008da3..8c0cc703c 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -1,5 +1,3 @@ -project(fwbuilder-gui) - find_package(OpenSSL REQUIRED) set(fwbuilder-gui_srcs diff --git a/src/gui/main.cpp b/src/gui/main.cpp index 47f5d10a7..af5753223 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -25,6 +25,7 @@ */ +#include "version.h" #include "global.h" #include "../common/commoninit.h" diff --git a/src/import/CMakeLists.txt b/src/import/CMakeLists.txt index 65274b247..2a478ca56 100644 --- a/src/import/CMakeLists.txt +++ b/src/import/CMakeLists.txt @@ -1,5 +1,3 @@ -project(import) - set(import_srcs getProtoByName.cpp PreImport.cpp diff --git a/src/iosacl/CMakeLists.txt b/src/iosacl/CMakeLists.txt index adcce8151..322ebdaa3 100644 --- a/src/iosacl/CMakeLists.txt +++ b/src/iosacl/CMakeLists.txt @@ -1,5 +1,3 @@ -project(iosacl) - set(iosacl_srcs iosacl.cpp ) @@ -18,6 +16,8 @@ ENDIF() target_compile_options(fwb_iosacl PRIVATE ${CXX_DEFAULT_FLAGS}) +set_source_files_properties(iosacl.cpp PROPERTIES COMPILE_DEFINITIONS PREFIX=\"${CMAKE_INSTALL_PREFIX}\") + install(TARGETS fwb_iosacl RUNTIME DESTINATION ${FWB_INSTALL_BINDIR}) qt5_use_modules(fwb_iosacl Widgets) diff --git a/src/iosacl/iosacl.cpp b/src/iosacl/iosacl.cpp index 7399225fb..13ff817b8 100644 --- a/src/iosacl/iosacl.cpp +++ b/src/iosacl/iosacl.cpp @@ -45,6 +45,7 @@ #include #include +#include "version.h" #include "CompilerDriver_iosacl.h" #include "fwbuilder/Resources.h" diff --git a/src/ipf/CMakeLists.txt b/src/ipf/CMakeLists.txt index 60dbb2a68..a21e44d4e 100644 --- a/src/ipf/CMakeLists.txt +++ b/src/ipf/CMakeLists.txt @@ -1,5 +1,3 @@ -project(ipf) - set(ipf_srcs ipf.cpp) @@ -17,6 +15,8 @@ ENDIF() target_compile_options(fwb_ipf PRIVATE ${CXX_DEFAULT_FLAGS}) +set_source_files_properties(ipf.cpp PROPERTIES COMPILE_DEFINITIONS PREFIX=\"${CMAKE_INSTALL_PREFIX}\") + install(TARGETS fwb_ipf RUNTIME DESTINATION ${FWB_INSTALL_BINDIR}) qt5_use_modules(fwb_ipf Widgets) diff --git a/src/ipf/ipf.cpp b/src/ipf/ipf.cpp index f2c5c294b..87f29b410 100644 --- a/src/ipf/ipf.cpp +++ b/src/ipf/ipf.cpp @@ -50,6 +50,7 @@ #include #include +#include "version.h" #include "CompilerDriver_ipf.h" #include "fwbuilder/Resources.h" diff --git a/src/ipfw/CMakeLists.txt b/src/ipfw/CMakeLists.txt index c40103573..44d269ea4 100644 --- a/src/ipfw/CMakeLists.txt +++ b/src/ipfw/CMakeLists.txt @@ -1,5 +1,3 @@ -project(ipfw) - set(ipfw_srcs ipfw.cpp) @@ -17,6 +15,8 @@ ENDIF() target_compile_options(fwb_ipfw PRIVATE ${CXX_DEFAULT_FLAGS}) +set_source_files_properties(ipfw.cpp PROPERTIES COMPILE_DEFINITIONS PREFIX=\"${CMAKE_INSTALL_PREFIX}\") + install(TARGETS fwb_ipfw RUNTIME DESTINATION ${FWB_INSTALL_BINDIR}) qt5_use_modules(fwb_ipfw Widgets) diff --git a/src/ipfw/ipfw.cpp b/src/ipfw/ipfw.cpp index 024584e94..1f078c28a 100644 --- a/src/ipfw/ipfw.cpp +++ b/src/ipfw/ipfw.cpp @@ -50,6 +50,7 @@ #include #include +#include "version.h" #include "CompilerDriver_ipfw.h" #include "fwbuilder/Resources.h" diff --git a/src/ipt/CMakeLists.txt b/src/ipt/CMakeLists.txt index 306ea3c9a..a8a8bced5 100644 --- a/src/ipt/CMakeLists.txt +++ b/src/ipt/CMakeLists.txt @@ -1,5 +1,3 @@ -project(ipt) - set(ipt_srcs ipt.cpp) @@ -17,6 +15,8 @@ ENDIF() target_compile_options(fwb_ipt PRIVATE ${CXX_DEFAULT_FLAGS}) +set_source_files_properties(ipt.cpp PROPERTIES COMPILE_DEFINITIONS PREFIX=\"${CMAKE_INSTALL_PREFIX}\") + install(TARGETS fwb_ipt RUNTIME DESTINATION ${FWB_INSTALL_BINDIR}) qt5_use_modules(fwb_ipt Widgets) diff --git a/src/ipt/ipt.cpp b/src/ipt/ipt.cpp index 009db88fc..ad3b2467c 100644 --- a/src/ipt/ipt.cpp +++ b/src/ipt/ipt.cpp @@ -30,6 +30,7 @@ #include #include +#include "version.h" #include "CompilerDriver_ipt.h" #include "fwbuilder/Resources.h" diff --git a/src/iptlib/CMakeLists.txt b/src/iptlib/CMakeLists.txt index ea19a843c..a1d2c47af 100644 --- a/src/iptlib/CMakeLists.txt +++ b/src/iptlib/CMakeLists.txt @@ -1,5 +1,3 @@ -project(iptlib) - set(iptlib_srcs CompilerDriver_ipt_policy.cpp OSData_ipt.cpp diff --git a/src/iptlib/CompilerDriver_ipt_run.cpp b/src/iptlib/CompilerDriver_ipt_run.cpp index 1a9035fa3..1fbb9950e 100644 --- a/src/iptlib/CompilerDriver_ipt_run.cpp +++ b/src/iptlib/CompilerDriver_ipt_run.cpp @@ -39,6 +39,7 @@ #include #include +#include "version.h" #include "CompilerDriver_ipt.h" #include "PolicyCompiler_ipt.h" #include "NATCompiler_ipt.h" diff --git a/src/juniper_lib/CMakeLists.txt b/src/juniper_lib/CMakeLists.txt index dcb57d490..ad9a1b9a6 100644 --- a/src/juniper_lib/CMakeLists.txt +++ b/src/juniper_lib/CMakeLists.txt @@ -1,5 +1,3 @@ -project(juniper_lib) - set(juniper_lib_srcs CompilerDriver_junosacl.cpp CompilerDriver_junosacl_run.cpp diff --git a/src/junosacl/CMakeLists.txt b/src/junosacl/CMakeLists.txt index efcd66885..a1b9b6561 100644 --- a/src/junosacl/CMakeLists.txt +++ b/src/junosacl/CMakeLists.txt @@ -1,5 +1,3 @@ -project(junosacl) - set(junosacl_srcs junosacl.cpp ) @@ -18,6 +16,8 @@ ENDIF() target_compile_options(fwb_junosacl PRIVATE ${CXX_DEFAULT_FLAGS}) +set_source_files_properties(junosacl.cpp PROPERTIES COMPILE_DEFINITIONS PREFIX=\"${CMAKE_INSTALL_PREFIX}\") + install(TARGETS fwb_junosacl RUNTIME DESTINATION ${FWB_INSTALL_BINDIR}) qt5_use_modules(fwb_junosacl Widgets) diff --git a/src/junosacl/junosacl.cpp b/src/junosacl/junosacl.cpp index 80c259a09..07dd319c2 100644 --- a/src/junosacl/junosacl.cpp +++ b/src/junosacl/junosacl.cpp @@ -45,6 +45,7 @@ #include #include +#include "version.h" #include "CompilerDriver_junosacl.h" #include "fwbuilder/Resources.h" diff --git a/src/libfwbuilder/etc/CMakeLists.txt b/src/libfwbuilder/etc/CMakeLists.txt index ff5e524f0..421bccd9a 100644 --- a/src/libfwbuilder/etc/CMakeLists.txt +++ b/src/libfwbuilder/etc/CMakeLists.txt @@ -1,4 +1,3 @@ -project(etc) configure_file(fwbuilder.dtd.in fwbuilder.dtd) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/fwbuilder.dtd DESTINATION ${FWB_INSTALL_DATADIR}) diff --git a/src/libfwbuilder/migration/CMakeLists.txt b/src/libfwbuilder/migration/CMakeLists.txt index 4509c4aca..c7d358169 100644 --- a/src/libfwbuilder/migration/CMakeLists.txt +++ b/src/libfwbuilder/migration/CMakeLists.txt @@ -1,4 +1,3 @@ -project(migration) -FILE(GLOB migration_files "${PROJECT_SOURCE_DIR}/*.xslt") +FILE(GLOB migration_files "${CMAKE_CURRENT_SOURCE_DIR}/*.xslt") install(FILES ${migration_files} DESTINATION ${FWB_INSTALL_DATADIR}/migration) diff --git a/src/libfwbuilder/src/fwbuilder/CMakeLists.txt b/src/libfwbuilder/src/fwbuilder/CMakeLists.txt index 7cdcb7c9e..b74b60b65 100644 --- a/src/libfwbuilder/src/fwbuilder/CMakeLists.txt +++ b/src/libfwbuilder/src/fwbuilder/CMakeLists.txt @@ -1,5 +1,3 @@ -project(libfwbuilder) - set(libfwbuilder_srcs InetAddr.cpp InetAddrMask.cpp @@ -75,6 +73,16 @@ set(libfwbuilder_srcs inet_net_pton.c uint128.cpp) +if(APPLE) + set(RES_DIR "../Resources") +elseif(WIN32) + set(RES_DIR "resources") +else() + set(RES_DIR "${CMAKE_INSTALL_PREFIX}/${FWB_INSTALL_DATADIR}") +endif() + +set_source_files_properties(Constants.cpp PROPERTIES COMPILE_DEFINITIONS RES_DIR=\"${RES_DIR}\") + add_library(fwbuilder STATIC ${libfwbuilder_srcs}) target_include_directories(fwbuilder PUBLIC diff --git a/src/libfwbuilder/src/fwbuilder/Constants.cpp b/src/libfwbuilder/src/fwbuilder/Constants.cpp index 95409da3b..b71a4d4fc 100644 --- a/src/libfwbuilder/src/fwbuilder/Constants.cpp +++ b/src/libfwbuilder/src/fwbuilder/Constants.cpp @@ -15,13 +15,14 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + To get a copy of the GNU General Public License, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "version.h" #include "fwbuilder/Constants.h" #if defined (__linux__) || defined (__FreeBSD_kernel__) || defined (__MINGW64__) || defined (__MINGW32__) || defined (__APPLE__) @@ -36,7 +37,7 @@ string Constants::res_dir; void Constants::init(const std::string &app_root_dir) { if (app_root_dir.empty()) res_dir = string(RES_DIR); - else res_dir = app_root_dir + FS_SEPARATOR + string(RES_DIR); + else res_dir = app_root_dir + "/" + string(RES_DIR); } const string Constants::getLibraryDescription() @@ -73,17 +74,17 @@ string Constants::getResourcesDirectory() string Constants::getResourcesFilePath() { - return getResourcesDirectory() + FS_SEPARATOR + "resources.xml"; + return getResourcesDirectory() + "/resources.xml"; } string Constants::getStandardObjectsFilePath() { - return getResourcesDirectory() + FS_SEPARATOR + "objects_init.xml"; + return getResourcesDirectory() + "/objects_init.xml"; } string Constants::getTemplatesObjectsFilePath() { - return getResourcesDirectory() + FS_SEPARATOR + "templates.xml"; + return getResourcesDirectory() + "/templates.xml"; } string Constants::getLocaleDirectory() diff --git a/src/libfwbuilder/src/fwbuilder/FWObjectDatabase.cpp b/src/libfwbuilder/src/fwbuilder/FWObjectDatabase.cpp index a04d00f90..79c4893ac 100644 --- a/src/libfwbuilder/src/fwbuilder/FWObjectDatabase.cpp +++ b/src/libfwbuilder/src/fwbuilder/FWObjectDatabase.cpp @@ -35,6 +35,7 @@ #include #include +#include "version.h" #include "fwbuilder/FWObject.h" #include "fwbuilder/FWObjectDatabase.h" diff --git a/src/libfwbuilder/src/fwbuilder/Resources.cpp b/src/libfwbuilder/src/fwbuilder/Resources.cpp index 80035b6f1..3fe279932 100644 --- a/src/libfwbuilder/src/fwbuilder/Resources.cpp +++ b/src/libfwbuilder/src/fwbuilder/Resources.cpp @@ -162,25 +162,25 @@ void Resources::loadSystemResources() string::size_type n=resfile.find_last_of("/\\"); string resDir = resfile.substr(0,n); - list pllist = getDirList( resDir + FS_SEPARATOR +PLATFORM_RES_DIR_NAME, + list pllist = getDirList( resDir + "/" +PLATFORM_RES_DIR_NAME, "xml" ); for (list::iterator lsi1=pllist.begin(); lsi1!=pllist.end(); lsi1++) { string::size_type n=lsi1->find_last_of("/\\")+1; string platform=lsi1->substr(n, lsi1->rfind(".xml")-n); - Resources *tr=new Resources(*lsi1); + Resources *tr=new Resources(*lsi1); platform_res[platform]=tr; } - list oslist = getDirList( resDir + FS_SEPARATOR +OS_RES_DIR_NAME, + list oslist = getDirList( resDir + "/" +OS_RES_DIR_NAME, "xml" ); for (list::iterator lsi2=oslist.begin(); lsi2!=oslist.end(); lsi2++) { string::size_type n=lsi2->find_last_of("/\\")+1; string os=lsi2->substr(n, lsi2->rfind(".xml")-n); - Resources *tr=new Resources(*lsi2); + Resources *tr=new Resources(*lsi2); os_res[os]=tr; } diff --git a/src/libfwbuilder/src/fwbuilder/Tools.cpp b/src/libfwbuilder/src/fwbuilder/Tools.cpp index 1de3889a4..8c1959b8b 100644 --- a/src/libfwbuilder/src/fwbuilder/Tools.cpp +++ b/src/libfwbuilder/src/fwbuilder/Tools.cpp @@ -139,7 +139,7 @@ list getDirList(const std::string &dir, continue; string pfile=de->d_name; - string rfile=dir+FS_SEPARATOR+pfile; + string rfile=dir+"/"+pfile; if (rfile.rfind(string(".")+ext)==rfile.size()-ext.size()-1) res.push_back(rfile); } @@ -149,16 +149,16 @@ list getDirList(const std::string &dir, struct _finddata_t c_file; intptr_t hFile; - string filepath=dir + FS_SEPARATOR + "*." + ext; + string filepath=dir + "/*." + ext; /* Find first file in current directory */ if( (hFile = _findfirst( filepath.c_str(), &c_file )) != -1L ) { - string rfile=dir+FS_SEPARATOR+c_file.name; + string rfile=dir+"/"+c_file.name; res.push_back(rfile); /* Find the rest of the files */ while( _findnext( hFile, &c_file ) == 0 ) { - string rfile=dir+FS_SEPARATOR+c_file.name; + string rfile=dir+"/"+c_file.name; res.push_back(rfile); } } diff --git a/src/libfwbuilder/src/fwbuilder/XMLTools.cpp b/src/libfwbuilder/src/fwbuilder/XMLTools.cpp index ecd2a4d10..b05ef7eee 100644 --- a/src/libfwbuilder/src/fwbuilder/XMLTools.cpp +++ b/src/libfwbuilder/src/fwbuilder/XMLTools.cpp @@ -26,7 +26,7 @@ - +#include "version.h" #include "fwbuilder/XMLTools.h" #include "fwbuilder/ThreadTools.h" @@ -115,6 +115,8 @@ static void xslt_error_handler(void *ctx, const char *msg, ...) *((string*)ctx)+=buf; } +const std::string XMLTools::defaultVersion = std::string(FWBUILDER_XML_VERSION); + xmlNodePtr XMLTools::getXmlChildNode(xmlNodePtr r,const char *child_name) { xmlNodePtr cur; @@ -197,7 +199,7 @@ xmlParserInputPtr fwbExternalEntityLoader(const char *URL, string fname; - fname=string(current_template_dir) + FS_SEPARATOR; + fname=string(current_template_dir) + "/"; string url=URL; string::size_type pos=url.find_last_of("/\\"); @@ -778,7 +780,7 @@ xmlDocPtr XMLTools::convert(xmlDocPtr doc, fname = template_dir; - fname = fname+FS_SEPARATOR+"migration"+FS_SEPARATOR+type_name+"_"+vers+".xslt"; + fname = fname+"/migration/"+type_name+"_"+vers+".xslt"; if (access(fname.c_str() , R_OK )!=0) { diff --git a/src/libfwbuilder/src/fwbuilder/XMLTools.h b/src/libfwbuilder/src/fwbuilder/XMLTools.h index 3ccecb4fc..a76c819f7 100644 --- a/src/libfwbuilder/src/fwbuilder/XMLTools.h +++ b/src/libfwbuilder/src/fwbuilder/XMLTools.h @@ -52,7 +52,7 @@ namespace libfwbuilder class XMLTools { public: - + static const std::string defaultVersion; static const char * FromXmlCast(xmlChar * c) { return reinterpret_cast(c); } static const char * FromXmlCast(const xmlChar * c) { return reinterpret_cast(c); } static xmlChar * ToXmlCast(char * c) { return reinterpret_cast(c); } @@ -94,7 +94,7 @@ class XMLTools const std::string &dtd_file, const UpgradePredicate *upgrade, const std::string &template_dir, - const std::string ¤t_version = std::string(FWBUILDER_XML_VERSION) + const std::string ¤t_version = defaultVersion ); static void setDTD(xmlDocPtr doc, @@ -197,7 +197,7 @@ class XMLTools const std::string &file_name, const std::string &type_name, const std::string &template_dir, - const std::string ¤t_version = std::string(FWBUILDER_XML_VERSION) + const std::string ¤t_version = defaultVersion ); /** diff --git a/src/libfwbuilder/src/fwcompiler/CMakeLists.txt b/src/libfwbuilder/src/fwcompiler/CMakeLists.txt index c1a791af7..657a31c91 100644 --- a/src/libfwbuilder/src/fwcompiler/CMakeLists.txt +++ b/src/libfwbuilder/src/fwcompiler/CMakeLists.txt @@ -1,5 +1,3 @@ -project(libfwcompiler) - set(libfwcompiler_srcs BaseCompiler.cpp Compiler.cpp diff --git a/src/libgui/CMakeLists.txt b/src/libgui/CMakeLists.txt index 8381bff3b..7cc57dbec 100644 --- a/src/libgui/CMakeLists.txt +++ b/src/libgui/CMakeLists.txt @@ -1,5 +1,3 @@ -project(libgui) - set(libgui_srcs ProjectPanel.cpp ProjectPanel_events.cpp diff --git a/src/libgui/CustomServiceDialog.cpp b/src/libgui/CustomServiceDialog.cpp index 420f57ce3..59c24ca79 100644 --- a/src/libgui/CustomServiceDialog.cpp +++ b/src/libgui/CustomServiceDialog.cpp @@ -32,6 +32,7 @@ #include "FWBTree.h" #include "CustomServiceDialog.h" #include "FWBSettings.h" +#include "FWBSettings_config.h" #include "FWCmdChange.h" #include "fwbuilder/Library.h" diff --git a/src/libgui/FWBAboutDialog.cpp b/src/libgui/FWBAboutDialog.cpp index 8bce0dff4..3ed8263ce 100644 --- a/src/libgui/FWBAboutDialog.cpp +++ b/src/libgui/FWBAboutDialog.cpp @@ -17,13 +17,14 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + To get a copy of the GNU General Public License, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "version.h" #include "global.h" #include "FWBAboutDialog.h" diff --git a/src/libgui/FWBSettings.cpp b/src/libgui/FWBSettings.cpp index 916ce5e87..ff015b416 100644 --- a/src/libgui/FWBSettings.cpp +++ b/src/libgui/FWBSettings.cpp @@ -31,6 +31,7 @@ #include "global.h" #include "FWBSettings.h" +#include "FWBSettings_config.h" #include "FWWindow.h" #include "ObjectManipulator.h" @@ -180,6 +181,11 @@ FWBSettings::~FWBSettings() #endif } +const QString FWBSettings::getApplicationNameForSettings() +{ + return "FirewallBuilder" GENERATION; +} + /** * to preserve behavior of the old versions of fwbuilder on Unix, the * default working dir is set to "." - current dir. diff --git a/src/libgui/FWBSettings.h b/src/libgui/FWBSettings.h index 713eb8f36..3ac8b095f 100644 --- a/src/libgui/FWBSettings.h +++ b/src/libgui/FWBSettings.h @@ -38,8 +38,6 @@ #include -#define SETTINGS_PATH_PREFIX "/" GENERATION - #include @@ -74,10 +72,7 @@ class FWBSettings : public QSettings FWBSettings(bool testData = false); ~FWBSettings(); - static QString getApplicationNameForSettings() - { - return "FirewallBuilder" GENERATION; - } + static const QString getApplicationNameForSettings(); void init(bool force_first_time_run=false); void save(); diff --git a/src/libgui/FWBSettings_config.h b/src/libgui/FWBSettings_config.h new file mode 100644 index 000000000..1b2531d36 --- /dev/null +++ b/src/libgui/FWBSettings_config.h @@ -0,0 +1,8 @@ +#ifndef __FWBSETTINGS_CONFIG_H_ +#define __FWBSETTINGS_CONFIG_H_ + +#include "version.h" +#define SETTINGS_PATH_PREFIX "/" GENERATION + +#endif + diff --git a/src/libgui/FWWindow.cpp b/src/libgui/FWWindow.cpp index 83b34b09c..7fd58ac89 100644 --- a/src/libgui/FWWindow.cpp +++ b/src/libgui/FWWindow.cpp @@ -28,6 +28,7 @@ */ +#include "version.h" #include "global.h" #include "check_update_url.h" diff --git a/src/libgui/FilterDialog.cpp b/src/libgui/FilterDialog.cpp index 0de064eda..f58016cbe 100644 --- a/src/libgui/FilterDialog.cpp +++ b/src/libgui/FilterDialog.cpp @@ -23,6 +23,7 @@ */ +#include "version.h" #include "global.h" #include "utils.h" #include "platforms.h" diff --git a/src/libgui/FindObjectWidget.cpp b/src/libgui/FindObjectWidget.cpp index 6f5f502d5..555c54538 100644 --- a/src/libgui/FindObjectWidget.cpp +++ b/src/libgui/FindObjectWidget.cpp @@ -33,6 +33,7 @@ #include "FWObjectDropArea.h" #include "FWBTree.h" #include "FWBSettings.h" +#include "FWBSettings_config.h" #include "ObjectTreeView.h" #include "RuleSetView.h" #include "ObjectEditor.h" diff --git a/src/libgui/RCS.cpp b/src/libgui/RCS.cpp index 30e1ac01c..50a9c17d1 100644 --- a/src/libgui/RCS.cpp +++ b/src/libgui/RCS.cpp @@ -30,9 +30,6 @@ #include "FWBApplication.h" #include "RCS.h" -// need this for FS_SEPARATOR -#include "fwbuilder/Tools.h" - //#include "FWWindow.h" #include diff --git a/src/libgui/StartTipDialog.cpp b/src/libgui/StartTipDialog.cpp index 800aa2522..2018a8277 100644 --- a/src/libgui/StartTipDialog.cpp +++ b/src/libgui/StartTipDialog.cpp @@ -23,6 +23,7 @@ */ +#include "version.h" #include "global.h" #include "utils.h" diff --git a/src/libgui/debugDialog.cpp b/src/libgui/debugDialog.cpp index 91422d121..8b96dce6c 100644 --- a/src/libgui/debugDialog.cpp +++ b/src/libgui/debugDialog.cpp @@ -24,7 +24,7 @@ */ - +#include "version.h" #include "global.h" #include "utils.h" diff --git a/src/libgui/instDialog_ui_ops.cpp b/src/libgui/instDialog_ui_ops.cpp index 131695fb6..6afbf90db 100644 --- a/src/libgui/instDialog_ui_ops.cpp +++ b/src/libgui/instDialog_ui_ops.cpp @@ -35,6 +35,7 @@ #include "instDialog.h" #include "FirewallInstaller.h" #include "FWBSettings.h" +#include "FWBSettings_config.h" #include "FWWindow.h" #include "InstallFirewallViewItem.h" #include "instOptionsDialog.h" diff --git a/src/libgui/utils_no_qt.cpp b/src/libgui/utils_no_qt.cpp index 897dbd2ab..a904bd60f 100644 --- a/src/libgui/utils_no_qt.cpp +++ b/src/libgui/utils_no_qt.cpp @@ -123,6 +123,6 @@ string strip(const string &s) string getPathToBinary(const string &pgm_name) { - return appRootDir + FS_SEPARATOR + pgm_name; + return appRootDir + "/" + pgm_name; } diff --git a/src/nxosacl/CMakeLists.txt b/src/nxosacl/CMakeLists.txt index 915bc5d76..9d7c39db4 100644 --- a/src/nxosacl/CMakeLists.txt +++ b/src/nxosacl/CMakeLists.txt @@ -1,5 +1,3 @@ -project(nxosacl) - set(nxosacl_srcs nxosacl.cpp ) @@ -18,6 +16,8 @@ ENDIF() target_compile_options(fwb_nxosacl PRIVATE ${CXX_DEFAULT_FLAGS}) +set_source_files_properties(nxosacl.cpp PROPERTIES COMPILE_DEFINITIONS PREFIX=\"${CMAKE_INSTALL_PREFIX}\") + install(TARGETS fwb_nxosacl RUNTIME DESTINATION ${FWB_INSTALL_BINDIR}) qt5_use_modules(fwb_nxosacl Widgets) diff --git a/src/nxosacl/nxosacl.cpp b/src/nxosacl/nxosacl.cpp index 1f5523a88..cae4080ff 100644 --- a/src/nxosacl/nxosacl.cpp +++ b/src/nxosacl/nxosacl.cpp @@ -45,6 +45,7 @@ #include #include +#include "version.h" #include "CompilerDriver_nxosacl.h" #include "fwbuilder/Resources.h" diff --git a/src/parsers/CMakeLists.txt b/src/parsers/CMakeLists.txt index cf56397a9..5593ac9c6 100644 --- a/src/parsers/CMakeLists.txt +++ b/src/parsers/CMakeLists.txt @@ -1,5 +1,3 @@ -project(parsers) - set(parsers_srcs IOSCfgLexer.cpp IOSCfgParser.cpp diff --git a/src/pf/CMakeLists.txt b/src/pf/CMakeLists.txt index 2ff0fcc60..9c5acbd51 100644 --- a/src/pf/CMakeLists.txt +++ b/src/pf/CMakeLists.txt @@ -1,5 +1,3 @@ -project(pf) - set(pf_srcs pf.cpp) @@ -17,6 +15,8 @@ ENDIF() target_compile_options(fwb_pf PRIVATE ${CXX_DEFAULT_FLAGS}) +set_source_files_properties(pf.cpp PROPERTIES COMPILE_DEFINITIONS PREFIX=\"${CMAKE_INSTALL_PREFIX}\") + install(TARGETS fwb_pf RUNTIME DESTINATION ${FWB_INSTALL_BINDIR}) qt5_use_modules(fwb_pf Widgets) diff --git a/src/pf/pf.cpp b/src/pf/pf.cpp index d431e0059..cfb0174ee 100644 --- a/src/pf/pf.cpp +++ b/src/pf/pf.cpp @@ -32,6 +32,7 @@ #include #include +#include "version.h" #include "CompilerDriver_pf.h" #include "fwbuilder/Resources.h" diff --git a/src/pflib/CMakeLists.txt b/src/pflib/CMakeLists.txt index 15001a537..6812da00c 100644 --- a/src/pflib/CMakeLists.txt +++ b/src/pflib/CMakeLists.txt @@ -1,5 +1,3 @@ -project(pflib) - set(pflib_srcs AutomaticRules_pf.cpp CompilerDriver_ipf.cpp diff --git a/src/pix/CMakeLists.txt b/src/pix/CMakeLists.txt index 0b903c9e6..40622c582 100644 --- a/src/pix/CMakeLists.txt +++ b/src/pix/CMakeLists.txt @@ -1,5 +1,3 @@ -project(pix) - set(pix_srcs pix.cpp) @@ -17,6 +15,8 @@ ENDIF() target_compile_options(fwb_pix PRIVATE ${CXX_DEFAULT_FLAGS}) +set_source_files_properties(pix.cpp PROPERTIES COMPILE_DEFINITIONS PREFIX=\"${CMAKE_INSTALL_PREFIX}\") + install(TARGETS fwb_pix RUNTIME DESTINATION ${FWB_INSTALL_BINDIR}) qt5_use_modules(fwb_pix Widgets) diff --git a/src/pix/pix.cpp b/src/pix/pix.cpp index ad329b226..11520a9b2 100644 --- a/src/pix/pix.cpp +++ b/src/pix/pix.cpp @@ -45,6 +45,7 @@ #include #include +#include "version.h" #include "CompilerDriver_pix.h" #include "fwbuilder/Resources.h" diff --git a/src/procurve_acl/CMakeLists.txt b/src/procurve_acl/CMakeLists.txt index d40e13cd9..1cb9f2995 100644 --- a/src/procurve_acl/CMakeLists.txt +++ b/src/procurve_acl/CMakeLists.txt @@ -1,5 +1,3 @@ -project(procurve_acl) - set(procurve_acl_srcs procurve_acl.cpp ) @@ -18,6 +16,8 @@ ENDIF() target_compile_options(fwb_procurve_acl PRIVATE ${CXX_DEFAULT_FLAGS}) +set_source_files_properties(procurve_acl.cpp PROPERTIES COMPILE_DEFINITIONS PREFIX=\"${CMAKE_INSTALL_PREFIX}\") + install(TARGETS fwb_procurve_acl RUNTIME DESTINATION ${FWB_INSTALL_BINDIR}) qt5_use_modules(fwb_procurve_acl Widgets) diff --git a/src/procurve_acl/procurve_acl.cpp b/src/procurve_acl/procurve_acl.cpp index 0597471c8..fd3cbdaa5 100644 --- a/src/procurve_acl/procurve_acl.cpp +++ b/src/procurve_acl/procurve_acl.cpp @@ -45,6 +45,7 @@ #include #include +#include "version.h" #include "CompilerDriver_procurve_acl.h" #include "fwbuilder/Resources.h" diff --git a/src/res/CMakeLists.txt b/src/res/CMakeLists.txt index a25b86af5..35830a23e 100644 --- a/src/res/CMakeLists.txt +++ b/src/res/CMakeLists.txt @@ -1,9 +1,8 @@ -project(res) configure_file(objects_init.xml.in objects_init.xml) configure_file(templates.xml.in templates.xml) -FILE(GLOB os_files "${PROJECT_SOURCE_DIR}/os/*.xml") -FILE(GLOB platform_files "${PROJECT_SOURCE_DIR}/platform/*.xml") -FILE(GLOB help_files "${PROJECT_SOURCE_DIR}/help/en_US/*.html" "${PROJECT_SOURCE_DIR}/help/en_US/*.png" "${PROJECT_SOURCE_DIR}/help/en_US/*.jpg") +FILE(GLOB os_files "${CMAKE_CURRENT_SOURCE_DIR}/os/*.xml") +FILE(GLOB platform_files "${CMAKE_CURRENT_SOURCE_DIR}/platform/*.xml") +FILE(GLOB help_files "${CMAKE_CURRENT_SOURCE_DIR}/help/en_US/*.html" "${CMAKE_CURRENT_SOURCE_DIR}/help/en_US/*.png" "${CMAKE_CURRENT_SOURCE_DIR}/help/en_US/*.jpg") install(FILES ${CMAKE_CURRENT_BINARY_DIR}/objects_init.xml diff --git a/src/version.h.in b/src/version.h.in new file mode 100644 index 000000000..9a69cbb6e --- /dev/null +++ b/src/version.h.in @@ -0,0 +1,9 @@ +#ifndef FWBUILDER_VERSION_H +#define FWBUILDER_VERSION_H + +#define GENERATION "@PROJECT_GENERATION@" +#define GENERATION_SHORT "@PROJECT_GENERATION_SHORT@" +#define VERSION "@PROJECT_VERSION@" +#define FWBUILDER_XML_VERSION "@FWBUILDER_XML_VERSION@" + +#endif // FWBUILDER_VERSION_H