From 4158e81757a55b35fc196be95dbc83c1bac485f5 Mon Sep 17 00:00:00 2001 From: Anton Adamansky Date: Thu, 5 Mar 2015 23:30:41 +0600 Subject: #115 --- .gitignore | 3 + ejdb.workspace | 19 +--- tcejdb/.gitignore | 5 + tcejdb/CMakeLists.txt | 93 ++++++++++++++---- tcejdb/CPack.cmake | 0 tcejdb/cmake/Modules/EjdbDebCpack.cmake | 0 tcejdb/src/basedefs.h.in | 2 +- tcejdb/src/ejdb/tests/CMakeLists.txt | 2 + tcejdb/src/tcbdb/tests/CMakeLists.txt | 3 + tcejdb/src/tcbdb/tools/CMakeLists.txt | 4 + tcejdb/src/tcfdb/tests/CMakeLists.txt | 5 +- tcejdb/src/tcfdb/tools/CMakeLists.txt | 3 + tcejdb/src/tchdb/tests/CMakeLists.txt | 3 + tcejdb/src/tchdb/tools/CMakeLists.txt | 2 + tcejdb/src/tctdb/tests/CMakeLists.txt | 4 + tcejdb/src/tctdb/tools/CMakeLists.txt | 2 + tcejdb/src/tcutil/tests/CMakeLists.txt | 9 +- tcejdb/tcejdb.project | 164 +++++++++++--------------------- tcejdb/win64-tc.cmake | 22 +++++ 19 files changed, 197 insertions(+), 148 deletions(-) create mode 100644 tcejdb/CPack.cmake create mode 100644 tcejdb/cmake/Modules/EjdbDebCpack.cmake create mode 100644 tcejdb/win64-tc.cmake diff --git a/.gitignore b/.gitignore index 3fd592e..9a1b222 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +/build-*/ +/Makefile + CMakeCache.txt CMakeFiles diff --git a/ejdb.workspace b/ejdb.workspace index b73af78..0b194ce 100644 --- a/ejdb.workspace +++ b/ejdb.workspace @@ -1,24 +1,15 @@ + - - - - - - - - - - + + - - - - + + diff --git a/tcejdb/.gitignore b/tcejdb/.gitignore index 7e47b9d..7f0a7a6 100644 --- a/tcejdb/.gitignore +++ b/tcejdb/.gitignore @@ -1,4 +1,9 @@ Makefile + +/.cmake_dirty +/tcejdb.mk + + build/* Testing/* src/old/* diff --git a/tcejdb/CMakeLists.txt b/tcejdb/CMakeLists.txt index 4ea35a5..f774572 100644 --- a/tcejdb/CMakeLists.txt +++ b/tcejdb/CMakeLists.txt @@ -1,13 +1,14 @@ cmake_minimum_required(VERSION 3.0) set(PROJECT_NAME "ejdb") -option(BUILD_SHARED_LIBS "Build shared libraries" ON) -option(BUILD_TESTS "Build EJDB test cases" OFF) - project(${PROJECT_NAME} VERSION 1.2.0 LANGUAGES C) - + +option(BUILD_SHARED_LIBS "Build shared libraries" ON) +option(BUILD_TESTS "Build EJDB test cases" OFF) +#option(TEST_TOOL_CMD "Test tool command", "") + if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") if (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7) message(FATAL_ERROR "GCC version must be at least 4.7!") @@ -41,6 +42,10 @@ set(MODULES tcutil tchdb tcbdb tctdb tcfdb bson ejdb) set(EJDB_GENERATED_DIR ${CMAKE_CURRENT_BINARY_DIR}/src/generated) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") +include(CheckIncludeFile) +include(CheckIncludeFiles) +include(CheckLibraryExists) +include(InstallRequiredSystemLibraries) include(EjdbUtils) macro_ensure_out_of_source_build( @@ -63,12 +68,13 @@ foreach(MODULE IN LISTS MODULES) endforeach(MODULE) add_library(ejdb SHARED ${ALL_SRC}) -if (NOT ENABLE_SHARED) +if (NOT BUILD_SHARED_LIBS) add_definitions(-DEJDB_NODLL) endif() add_library(ejdb_p STATIC ${ALL_SRC}) + find_package(Threads REQUIRED CMAKE_THREAD_PREFER_PTHREAD) if (CMAKE_USE_WIN32_THREADS_INIT) add_definitions(-D_TC_WIN32_THREADS) @@ -77,7 +83,10 @@ elseif (CMAKE_USE_PTHREADS_INIT) else() mesage(FATAL_ERROR "Unable to find suitable threading library") endif(CMAKE_USE_WIN32_THREADS_INIT) -list(APPEND EJDB_LLIBRARIES ${CMAKE_THREAD_LIBS_INIT}) + +if (NOT WIN32) + list(APPEND EJDB_LLIBRARIES ${CMAKE_THREAD_LIBS_INIT}) +endif() find_library(M_LIB m) if (NOT M_LIB) @@ -109,7 +118,43 @@ if (LZO_FOUND) list(APPEND EJDB_INCLUDE_DIRS ${LZO_INCLUDE_DIR}) endif(LZO_FOUND) -include(CheckIncludeFile) +if (WIN32) + check_include_file(windows.h HAVE_WINDOWS_H) + if (NOT HAVE_WINDOWS_H) + message(FATAL_ERROR "Unable to find windows.h include file") + endif() + check_include_file(time.h HAVE_TIME_H) + if (NOT HAVE_TIME_H) + message(FATAL_ERROR "Unable to find time.h include file") + endif() + check_include_file(pcre.h HAVE_PCRE_H) + if (NOT HAVE_PCRE_H) + message(FATAL_ERROR "Unable to find pcre.h include file") + endif() + check_include_file(pcreposix.h HAVE_PCREPOSIX_H) + if (NOT HAVE_PCREPOSIX_H) + message(FATAL_ERROR "Unable to find pcreposix.h include file") + endif() + check_library_exists(pcre pcre_compile "" HAVE_PCRE_LIB) + #check_library_exists(pcreposix regexec "" HAVE_PCREPOSIX_LIB) + if (NOT HAVE_PCRE_LIB) + message(FATAL_ERROR "Unable to find pcre lib") + endif() + check_library_exists(winpthread pthread_exit "" HAVE_WINPTHREAD) + if (NOT HAVE_WINPTHREAD) + message(FATAL_ERROR "Unable to winpthread lib") + endif() + list(INSERT EJDB_LLIBRARIES 0 -lwinpthread -lpcreposix -lpcre) + add_definitions(-DPCRE_STATIC) + +else() + + check_include_file(glob.h HAVE_GLOB_H) + if (NOT HAVE_GLOB_H) + message(FATAL_ERROR "Unable to find glob.h include file") + endif() +endif(WIN32) + foreach(HF IN ITEMS stdlib stdint unistd dirent stddef) string(TOUPPER "${HF}" UHF) check_include_file(${HF}.h "_TC_HAVE_${UHF}") @@ -127,10 +172,15 @@ target_link_libraries(ejdb_p ${EJDB_LLIBRARIES}) #todo check the host system! -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -fsigned-char -pedantic") -set(CMAKE_C_FLAGS_DEBUG "-O0 -Wfatal-errors -Werror -DDEBUG -D_DEBUG -UNDEBUG") -set(CMAKE_C_FLAGS_RELEASE "-O3 -Wfatal-errors -DNDEBUG") -set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -fsigned-char -pedantic -Wfatal-errors") +set(CMAKE_C_FLAGS_DEBUG "-O0 -g -Werror -DDEBUG -D_DEBUG -UNDEBUG") +set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG") +set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -D_DEBUG -UNDEBUG") + +if (WIN32) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-pedantic-ms-format") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++") +endif(WIN32) if (CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") @@ -185,7 +235,7 @@ set_target_properties(ejdb PROPERTIES set_target_properties(ejdb_p PROPERTIES VERSION ${ejdb_VERSION} - DEFINE_SYMBOL EJDB_NODLL) + COMPILE_FLAGS "-DEJDB_NODLL") install(TARGETS ejdb EXPORT ejdb-exports @@ -198,17 +248,20 @@ install(TARGETS ejdb install(EXPORT ejdb-exports DESTINATION ${LIB_INSTALL_DIR}/${PROJECT_NAME}) -export(EXPORT ejdb-exports) +export(EXPORT ejdb-exports) -include(InstallRequiredSystemLibraries) +#todo if +include(EjdbDebCpack) message("") message("#############################################") -message(" BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}") -message(" BUILD_TESTS: ${BUILD_TESTS}") -message(" LINK LIBS: ${EJDB_LLIBRARIES}") -message(" INCLUDE DIRS: ${EJDB_INCLUDE_DIRS}") -message(" SOURCES: ${ALL_SRC}") -message(" PUB_HDRS: ${PUB_HDRS}") +message("CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") +message("\nBUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}") +message("\nBUILD_TESTS: ${BUILD_TESTS}") +message("\nLINK LIBS: ${EJDB_LLIBRARIES}") +message("\nINCLUDE DIRS: ${EJDB_INCLUDE_DIRS}") +message("\nSOURCES: ${ALL_SRC}") +message("\nPUB_HDRS: ${PUB_HDRS}") message("#############################################") message("") + diff --git a/tcejdb/CPack.cmake b/tcejdb/CPack.cmake new file mode 100644 index 0000000..e69de29 diff --git a/tcejdb/cmake/Modules/EjdbDebCpack.cmake b/tcejdb/cmake/Modules/EjdbDebCpack.cmake new file mode 100644 index 0000000..e69de29 diff --git a/tcejdb/src/basedefs.h.in b/tcejdb/src/basedefs.h.in index ea82111..055486a 100644 --- a/tcejdb/src/basedefs.h.in +++ b/tcejdb/src/basedefs.h.in @@ -38,7 +38,7 @@ EJDB_EXTERN_C_START #endif #if (defined(_WIN32) || defined(_WIN64)) -# ifdef EJDB_NODLL +# if (defined(EJDB_NODLL) || defined(EJDB_STATIC)) # define EJDB_EXPORT # else # ifdef EJDB_API_EXPORTS diff --git a/tcejdb/src/ejdb/tests/CMakeLists.txt b/tcejdb/src/ejdb/tests/CMakeLists.txt index 8729789..fb36af8 100644 --- a/tcejdb/src/ejdb/tests/CMakeLists.txt +++ b/tcejdb/src/ejdb/tests/CMakeLists.txt @@ -4,6 +4,8 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${TEST_DATA_DIR}) foreach(TC RANGE 1 5) add_executable(ejdbtest${TC} ejdbtest${TC}.c) + set_target_properties(ejdbtest${TC} PROPERTIES + COMPILE_FLAGS "-DEJDB_STATIC") add_test(NAME ejdbtest${TC} WORKING_DIRECTORY ${TEST_DATA_DIR} COMMAND ${TEST_TOOL_CMD} $) endforeach() diff --git a/tcejdb/src/tcbdb/tests/CMakeLists.txt b/tcejdb/src/tcbdb/tests/CMakeLists.txt index 6c534e8..0014eea 100644 --- a/tcejdb/src/tcbdb/tests/CMakeLists.txt +++ b/tcejdb/src/tcbdb/tests/CMakeLists.txt @@ -7,6 +7,9 @@ add_executable(tcbmttest tcbmttest.c) add_dependencies(tcbtest tchmgr) add_dependencies(tcbmttest tchmgr tchmttest) +set_target_properties(tcbtest tcbmttest PROPERTIES + COMPILE_FLAGS "-DEJDB_STATIC") + add_test(NAME tcbtest1 WORKING_DIRECTORY ${TEST_DATA_DIR} COMMAND ${TEST_TOOL_CMD} $ write casket 50000 5 5 5000 5 5) diff --git a/tcejdb/src/tcbdb/tools/CMakeLists.txt b/tcejdb/src/tcbdb/tools/CMakeLists.txt index 39642dc..10de211 100644 --- a/tcejdb/src/tcbdb/tools/CMakeLists.txt +++ b/tcejdb/src/tcbdb/tools/CMakeLists.txt @@ -1,6 +1,10 @@ link_libraries(ejdb_p) add_executable(tcbmgr tcbmgr.c) +set_target_properties(tcbmgr PROPERTIES + COMPILE_FLAGS "-DEJDB_STATIC") + + install(TARGETS tcbmgr FRAMEWORK DESTINATION ${FRAMEWORK_INSTALL_DIR} LIBRARY DESTINATION ${LIB_INSTALL_DIR} diff --git a/tcejdb/src/tcfdb/tests/CMakeLists.txt b/tcejdb/src/tcfdb/tests/CMakeLists.txt index 82f9665..3e7a139 100644 --- a/tcejdb/src/tcfdb/tests/CMakeLists.txt +++ b/tcejdb/src/tcfdb/tests/CMakeLists.txt @@ -4,10 +4,13 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${TEST_DATA_DIR}) add_executable(tcftest tcftest.c) add_executable(tcfmttest tcfmttest.c) - add_dependencies(tcftest tcfmgr) add_dependencies(tcfmttest tcfmgr) +set_target_properties(tcftest tcfmttest PROPERTIES + COMPILE_FLAGS "-DEJDB_STATIC") + + add_test(NAME tcftest1 WORKING_DIRECTORY ${TEST_DATA_DIR} COMMAND ${TEST_TOOL_CMD} $ write casket 50000 50) diff --git a/tcejdb/src/tcfdb/tools/CMakeLists.txt b/tcejdb/src/tcfdb/tools/CMakeLists.txt index a467c16..2ab76be 100644 --- a/tcejdb/src/tcfdb/tools/CMakeLists.txt +++ b/tcejdb/src/tcfdb/tools/CMakeLists.txt @@ -1,6 +1,9 @@ link_libraries(ejdb_p) add_executable(tcfmgr tcfmgr.c) +set_target_properties(tcfmgr PROPERTIES + COMPILE_FLAGS "-DEJDB_STATIC") + install(TARGETS tcfmgr FRAMEWORK DESTINATION ${FRAMEWORK_INSTALL_DIR} LIBRARY DESTINATION ${LIB_INSTALL_DIR} diff --git a/tcejdb/src/tchdb/tests/CMakeLists.txt b/tcejdb/src/tchdb/tests/CMakeLists.txt index aaad448..d9f4c87 100644 --- a/tcejdb/src/tchdb/tests/CMakeLists.txt +++ b/tcejdb/src/tchdb/tests/CMakeLists.txt @@ -7,6 +7,9 @@ add_executable(tchmttest tchmttest.c) add_dependencies(tchtest tchmgr) add_dependencies(tchmttest tchmgr) +set_target_properties(tchtest tchmttest PROPERTIES + COMPILE_FLAGS "-DEJDB_STATIC") + add_test(NAME tchtest1 WORKING_DIRECTORY ${TEST_DATA_DIR} COMMAND ${TEST_TOOL_CMD} $ write casket 50000 5000 5 5) diff --git a/tcejdb/src/tchdb/tools/CMakeLists.txt b/tcejdb/src/tchdb/tools/CMakeLists.txt index a47f70f..bfaa086 100644 --- a/tcejdb/src/tchdb/tools/CMakeLists.txt +++ b/tcejdb/src/tchdb/tools/CMakeLists.txt @@ -1,5 +1,7 @@ link_libraries(ejdb_p) add_executable(tchmgr tchmgr.c) +set_target_properties(tchmgr PROPERTIES + COMPILE_FLAGS "-DEJDB_STATIC") install(TARGETS tchmgr FRAMEWORK DESTINATION ${FRAMEWORK_INSTALL_DIR} diff --git a/tcejdb/src/tctdb/tests/CMakeLists.txt b/tcejdb/src/tctdb/tests/CMakeLists.txt index 64b1112..76d0db2 100644 --- a/tcejdb/src/tctdb/tests/CMakeLists.txt +++ b/tcejdb/src/tctdb/tests/CMakeLists.txt @@ -7,6 +7,10 @@ add_executable(tctmttest tctmttest.c) add_dependencies(tcttest tchmgr tcbmgr) add_dependencies(tctmttest tchmgr tcbmgr) +set_target_properties(tcttest tctmttest PROPERTIES + COMPILE_FLAGS "-DEJDB_STATIC") + + add_test(NAME tcttest1 WORKING_DIRECTORY ${TEST_DATA_DIR} COMMAND ${TEST_TOOL_CMD} $ write casket 50000 5000 5 5) diff --git a/tcejdb/src/tctdb/tools/CMakeLists.txt b/tcejdb/src/tctdb/tools/CMakeLists.txt index 1490e3b..0b55b93 100644 --- a/tcejdb/src/tctdb/tools/CMakeLists.txt +++ b/tcejdb/src/tctdb/tools/CMakeLists.txt @@ -1,5 +1,7 @@ link_libraries(ejdb_p) add_executable(tctmgr tctmgr.c) +set_target_properties(tctmgr PROPERTIES + COMPILE_FLAGS "-DEJDB_STATIC") install(TARGETS tctmgr FRAMEWORK DESTINATION ${FRAMEWORK_INSTALL_DIR} diff --git a/tcejdb/src/tcutil/tests/CMakeLists.txt b/tcejdb/src/tcutil/tests/CMakeLists.txt index 15408fc..6d5a64b 100644 --- a/tcejdb/src/tcutil/tests/CMakeLists.txt +++ b/tcejdb/src/tcutil/tests/CMakeLists.txt @@ -1,8 +1,13 @@ -link_libraries(ejdb) +link_libraries(ejdb_p) set(TEST_DATA_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${TEST_DATA_DIR}) add_executable(tcutest tcutest.c) +add_executable(tcumttest tcumttest.c) + +set_target_properties(tcutest tcumttest + PROPERTIES + COMPILE_FLAGS "-DEJDB_STATIC") add_test(NAME tcutest1 WORKING_DIRECTORY ${TEST_DATA_DIR} COMMAND ${TEST_TOOL_CMD} $ @@ -60,8 +65,6 @@ add_test(NAME tcutest14 WORKING_DIRECTORY ${TEST_DATA_DIR} COMMAND ${TEST_TOOL_CMD} $ wicked 50000) -add_executable(tcumttest tcumttest.c) - add_test(NAME tcumttest1 WORKING_DIRECTORY ${TEST_DATA_DIR} COMMAND ${TEST_TOOL_CMD} $ combo 5 50000 500) diff --git a/tcejdb/tcejdb.project b/tcejdb/tcejdb.project index c4d433a..3833b52 100644 --- a/tcejdb/tcejdb.project +++ b/tcejdb/tcejdb.project @@ -2,7 +2,7 @@ - + @@ -139,6 +157,16 @@ + + + + + + + + + + @@ -149,91 +177,16 @@ - - - - - - - - - - - - - - - - - - - cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1 - make clean && mingw32-make -j4 - make clean - make -j4 - - - - None - $(WorkspacePath)/build-debug - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - cmake .. -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1 - mingw32-make clean && mingw32-make -j4 - mingw32-make clean - mingw32-make -j4 - - - - None - $(WorkspacePath)/build-debug - - - - - - - - - - - - - - - - - + + + + - + @@ -244,16 +197,15 @@ - - cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=1 - make clean && make -j4 - make clean - make -j4 + + + + - None - $(WorkspacePath)/build-release + + @@ -266,13 +218,16 @@ - - + + - + + + + - + @@ -283,16 +238,15 @@ - - cmake .. -G "MinGW Makefiles" -DCMAKE_EXPORT_COMPILE_COMMANDS=1 - mingw32-make clean && mingw32-make -j4 - mingw32-make clean - mingw32-make -j4 + + + + - None - $(WorkspacePath)/build-release + + @@ -306,12 +260,4 @@ - - - - - - - - diff --git a/tcejdb/win64-tc.cmake b/tcejdb/win64-tc.cmake new file mode 100644 index 0000000..93abd5d --- /dev/null +++ b/tcejdb/win64-tc.cmake @@ -0,0 +1,22 @@ +if (NOT MXE_HOME) + set(MXE_HOME /home/adam/Projects/mxe) +endif() +if (NOT MXE_CFG) + set(MXE_CFG "x86_64-w64-mingw32.static") +endif() + +set(CMAKE_SYSTEM_NAME Windows) +set(MSYS 1) +set(CMAKE_FIND_ROOT_PATH ${MXE_HOME}/usr/${MXE_CFG}) +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_C_COMPILER ${MXE_HOME}/usr/bin/${MXE_CFG}-gcc) +set(CMAKE_CXX_COMPILER ${MXE_HOME}/usr/bin/${MXE_CFG}-g++) +set(CMAKE_Fortran_COMPILER ${MXE_HOME}/usr/bin/${MXE_CFG}-gfortran) +set(CMAKE_RC_COMPILER ${MXE_HOME}/usr/bin/${MXE_CFG}-windres) +set(CMAKE_MODULE_PATH "${MXE_HOME}/src/cmake" ${CMAKE_MODULE_PATH}) # For mxe FindPackage scripts +#set(CMAKE_INSTALL_PREFIX ${MXE_HOME}/usr/x86_64-w64-mingw32.static CACHE PATH "Installation Prefix") +set(CMAKE_CROSS_COMPILING ON) # Workaround for http://www.cmake.org/Bug/view.php?id=14075 +set(CMAKE_RC_COMPILE_OBJECT " -O coff -o ") # Workaround for buggy windres rules +set(PKG_CONFIG_EXECUTABLE ${MXE_HOME}/usr/bin/${MXE_CFG}-pkg-config) -- cgit v1.2.3