Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update from dev #48

Merged
merged 12 commits into from
Mar 11, 2024
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
/cmake-build-release
/bin
/thrid-party/
/mingw32_x86_build/
/build/mingw32_x86/
/third-party/
/cmake-build-debug-mingw/
/cmake-build-debug-risc-v/
/cmake-build-release-visual-studio/
102 changes: 68 additions & 34 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,46 +1,80 @@
cmake_minimum_required(VERSION 3.25.1)

SET(BUILD_TESTS OFF)
project(collections_commons C)

if (BUILD_TESTS)
message(STATUS "Tests are included. Set BUILD_TESTS=OFF to diable.")
else ()
message(STATUS "Tests not included. Set BUILD_TESTS=ON to build tests.")
endif ()
# check if Doxygen is installed
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")

cmake_minimum_required(VERSION 3.25.1)
project(collections_commons C)
OPTION(BUILD_TESTS "Build unit tests" ON)

OPTION(BUILD_DOC "Build documentation" ON)

if (BUILD_TESTS)
message(STATUS "Tests are included. Set BUILD_TESTS to OFF to diable.")
else ()
message(STATUS "Tests not included. Set BUILD_TESTS to ON to enable tests.")
endif ()

if (BUILD_DOC)
find_package(Doxygen REQUIRED)

if (DOXYGEN_FOUND)
# set input and output files
set(DOXYGEN_IN doc/Doxyfile.in)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)


# request to configure the file
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
message(STATUS "Doxygen build started")

# note the option ALL which allows to build the docs together with the application
add_custom_target(${PROJECT_NAME}_doc ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM )
else (DOXYGEN_FOUND)
message(STATUS "Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)
endif ()

#ADD GTEST

endif ()

### OUTPUT LIBRARY CONFIGURATION PER COMPILER ###
set(CMAKE_C_STANDARD 99)
if (CMAKE_GENERATOR MATCHES "Visual Studio")
set(CMAKE_ROOT_DIRECTORY ${CMAKE_SOURCE_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/)
#set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/compiled)
#set(CMAKE_PDB_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/pdb)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/archive)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/msbuild)
set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/msbuild/compiled)
set(CMAKE_PDB_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/msbuild/pdb)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/msbuild/archive)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/msbuild/lib)
elseif (CMAKE_GENERATOR MATCHES "MinGW Makefiles")
set(CMAKE_SYSTEM_PROCESSOR x64)
set(CMAKE_ROOT_DIRECTORY ${CMAKE_SOURCE_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/mingw32_x86_build/)
#set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/mingw32_x86_build/compiled)
#set(CMAKE_PDB_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/mingw32_x86_build/pdb)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/mingw32_x86_build/archive)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/mingw32_x86_build/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/mingw32_x86/)
#set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/mingw32_x86/compiled)
#set(CMAKE_PDB_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/mingw32_x86/pdb)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/mingw32_x86/archive)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/mingw32_x86/lib)
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set(CMAKE_ROOT_DIRECTORY ${CMAKE_SOURCE_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/gnu_build/)
#set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/gnu_build/compiled)
#set(CMAKE_PDB_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/gnu_build/pdb)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/gnu_build/archive)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/gnu_build/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/gnu/)
#set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/gnu/compiled)
#set(CMAKE_PDB_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/gnu/pdb)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/gnu/archive)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/gnu/lib)
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(CMAKE_ROOT_DIRECTORY ${CMAKE_SOURCE_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/clang_build/)
#set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/clang_build/compiled)
#set(CMAKE_PDB_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/clang_build/pdb)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/clang_build/archive)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/clang_build/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/clang/)
#set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/clang/compiled)
#set(CMAKE_PDB_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/clang/pdb)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/clang/archive)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/clang/lib)
endif ()
endif ()
endif ()
Expand All @@ -54,14 +88,14 @@ file(GLOB_RECURSE SOURCES_FILES
${PROJECT_SOURCE_DIR}/src/*.c
)

#ADD GTEST
if (BUILD_TESTS)
add_subdirectory(tests)
add_subdirectory(third-party/googletest)
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
if (BUILD_TESTS)
add_subdirectory(tests)
add_subdirectory(third-party/googletest)
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
endif ()
endif ()


find_package(Threads REQUIRED)
if (THREADS_HAVE_PTHREAD_ARG)
target_compile_options(${PROJECT_NAME} PUBLIC "-pthread")
Expand Down
Loading
Loading