diff --git a/.gitignore b/.gitignore index 465d6ef..39124d5 100644 --- a/.gitignore +++ b/.gitignore @@ -3,10 +3,16 @@ *.P *.zip *nbproject* -src/oastat +oastat *.exe oastat-win.zip oastat-win/ sql/create_tables/oastat_create_tables_mysql.sql sql/create_tables/oastat_create_tables_posgrel.sql sql/create_tables/oastat_create_tables_sqlite.sql + +cmake_install.cmake +CMake* +-CMakeLists.txt +CPack* +Makefile diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..f44e48f --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 2.8.9) +project (oastat) +find_package(Boost COMPONENTS program_options REQUIRED) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -std=c++11") + +file(GLOB SOURCES "src/*.cpp" "src/*/*.cpp") + +add_executable(oastat ${SOURCES}) +TARGET_LINK_LIBRARIES( oastat ${Boost_LIBRARIES} ) +target_link_libraries( oastat cppdb gcrypt gpg-error) diff --git a/README.md b/README.md index a488b1e..992ef87 100644 --- a/README.md +++ b/README.md @@ -12,14 +12,14 @@ Homepage: * libgcrypt * boost_program_options -On Ubuntu (15.04 or later) all requirements can be installed with: sudo apt-get install build-essential libboost-program-options-dev libcppdb-dev libgcrypt20-dev +On Ubuntu (15.04 or later) all requirements can be installed with: sudo apt-get install build-essential libboost-program-options-dev libcppdb-dev libgcrypt20-dev cmake On earlier versions CppDb must be installed manually. -CppDb can be disabled from the build by adding the line: -USECPPDB=0 to src/Makefile.local (file must be created) - -Go to ./src and type "make" -The executable will be in the same folder. +To compile: +``` +cmake . +make +``` To create the database scripts: cd sql/create_tables/ diff --git a/extra/docker_builder/Dockerfile b/extra/docker_builder/Dockerfile index 1d0de66..d09e94e 100644 --- a/extra/docker_builder/Dockerfile +++ b/extra/docker_builder/Dockerfile @@ -1,7 +1,9 @@ FROM ubuntu:16.04 -RUN apt-get update && apt-get install -y build-essential libboost-program-options-dev libcppdb-dev libboost-dev libgcrypt11-dev +RUN apt-get update && apt-get install -y build-essential libboost-program-options-dev libcppdb-dev libboost-dev libgcrypt11-dev cmake RUN mkdir -p /opt/data COPY . /opt/data/ + +RUN cd /opt/data/ && cmake . && make diff --git a/src/Makefile b/src/Makefile deleted file mode 100644 index 87e84e6..0000000 --- a/src/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -ifndef USECPPDB -USECPPDB=1 -endif -ifndef PROGRAMNAME -PROGRAMNAME=oastat -endif -ifdef CROSS -CXX=$(CROSS)g++ -endif - -BASE_LIBS=-lgcrypt -lboost_program_options -lgpg-error -BASE_CFLAGS=-c -g -O1 -Wall -std=c++11 - --include Makefile.local - -O_FILES=oastat.o oastatstruct.o oss2db/kill2db.o oss2db/init2db.o oss2db/shutdown2db.o oss2db/userinfo2db.o oss2db/Disconnect2Db.o oss2db/Award2Db.o oss2db/Ctf2Db.o oss2db/Point2Db.o oss2db/Ctf1f2Db.o oss2db/Elimination2Db.o oss2db/CtfElimination2Db.o oss2db/Harvester2Db.o oss2db/Challenge2Db.o oss2db/Warmup2Db.o oss2db/Accuracy2Db.o - -ifeq ($(USECPPDB),1) - BASE_LIBS+= -lcppdb - O_FILES+= db/Db2CppDb.o - BASE_CFLAGS+= -DUSECPPDB=1 -endif - -O_FILES+= db/Db2Xml.o -BASE_CFLAGS+= -DUSEXML=1 - -total: ${PROGRAMNAME} - -clean: - rm -f */*.o *.o *.P */*.P */*/*.P ${PROGRAMNAME} - -${PROGRAMNAME}: $(O_FILES) - $(CXX) -O -o ${PROGRAMNAME} $(O_FILES) $(BASE_LIBS) - -%.o : %.cpp - $(CXX) -MD ${BASE_CFLAGS} -o $@ $< - @mkdir -p .$(CROSS)deps/$(basename $*); cp $*.d .$(CROSS)deps/$*.P; \ - sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ - -e '/^$$/ d' -e 's/$$/ :/' < $*.d >> .$(CROSS)deps/$*.P; \ - rm -f $*.d - --include .$(CROSS)deps/*.P --include .$(CROSS)deps/*/*.P diff --git a/src/oastat.cpp b/src/oastat.cpp index ec3e994..b5b6548 100644 --- a/src/oastat.cpp +++ b/src/oastat.cpp @@ -31,7 +31,7 @@ https://github.com/sago007/oastat/ #include #include #include -#include +#include #include #include @@ -112,7 +112,7 @@ static int processStdIn(std::istream &in_p, std::vector osslist; + std::deque osslist; try { while ( std::getline(in_p,line) ) { oss.clear();