generated from AfonsoCMSousa/CPP-Template
New: Base Project.
This commit is contained in:
+31
-32
@@ -15,36 +15,35 @@ include_directories(${CMAKE_SOURCE_DIR}/libraries)
|
||||
|
||||
# Gather all source files (.cpp, .c)
|
||||
file(GLOB_RECURSE PROJECT_SOURCES
|
||||
${CMAKE_SOURCE_DIR}/include/*.cpp
|
||||
${CMAKE_SOURCE_DIR}/include/*.c
|
||||
${CMAKE_SOURCE_DIR}/libraries/*.cpp
|
||||
${CMAKE_SOURCE_DIR}/libraries/*.c
|
||||
${CMAKE_SOURCE_DIR}/source/*.cpp
|
||||
${CMAKE_SOURCE_DIR}/source/*.c
|
||||
${CMAKE_SOURCE_DIR}/include/*.cpp
|
||||
${CMAKE_SOURCE_DIR}/include/*.c
|
||||
${CMAKE_SOURCE_DIR}/libraries/*.cpp
|
||||
${CMAKE_SOURCE_DIR}/libraries/*.c
|
||||
${CMAKE_SOURCE_DIR}/source/*.cpp
|
||||
${CMAKE_SOURCE_DIR}/source/*.c
|
||||
)
|
||||
|
||||
# Gather all header files (.hpp, .h)
|
||||
file(GLOB_RECURSE PROJECT_HEADERS
|
||||
${CMAKE_SOURCE_DIR}/include/*.hpp
|
||||
${CMAKE_SOURCE_DIR}/include/*.h
|
||||
${CMAKE_SOURCE_DIR}/libraries/*.hpp
|
||||
${CMAKE_SOURCE_DIR}/libraries/*.h
|
||||
${CMAKE_SOURCE_DIR}/source/*.hpp
|
||||
${CMAKE_SOURCE_DIR}/source/*.h
|
||||
${CMAKE_SOURCE_DIR}/include/*.hpp
|
||||
${CMAKE_SOURCE_DIR}/include/*.h
|
||||
${CMAKE_SOURCE_DIR}/libraries/*.hpp
|
||||
${CMAKE_SOURCE_DIR}/libraries/*.h
|
||||
${CMAKE_SOURCE_DIR}/source/*.hpp
|
||||
${CMAKE_SOURCE_DIR}/source/*.h
|
||||
)
|
||||
|
||||
# Allow user to set output program name
|
||||
option(OUTPUT_NAME "Name of the output executable" "")
|
||||
if(OUTPUT_NAME STREQUAL "")
|
||||
set(EXECUTABLE_NAME ${PROJECT_NAME})
|
||||
set(EXECUTABLE_NAME ${PROJECT_NAME})
|
||||
else()
|
||||
set(EXECUTABLE_NAME ${OUTPUT_NAME})
|
||||
set(EXECUTABLE_NAME ${OUTPUT_NAME})
|
||||
endif()
|
||||
|
||||
# Add executable with all sources
|
||||
add_executable(${EXECUTABLE_NAME}
|
||||
${PROJECT_SOURCES}
|
||||
${PROJECT_HEADERS}
|
||||
${PROJECT_SOURCES}
|
||||
)
|
||||
|
||||
# Set output name property (for consistency)
|
||||
@@ -52,24 +51,24 @@ set_target_properties(${EXECUTABLE_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_NAM
|
||||
|
||||
# Enable warnings and extra diagnostics
|
||||
if (MSVC)
|
||||
target_compile_options(${EXECUTABLE_NAME} PRIVATE /W4 /permissive- /analyze)
|
||||
target_compile_options(${EXECUTABLE_NAME} PRIVATE /W4 /permissive- /analyze)
|
||||
else()
|
||||
target_compile_options(${EXECUTABLE_NAME} PRIVATE
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wpedantic
|
||||
-Wshadow
|
||||
-Wconversion
|
||||
-Wsign-conversion
|
||||
-Wuninitialized
|
||||
-Wunused
|
||||
-Werror=return-type
|
||||
-fsanitize=address,undefined
|
||||
-g
|
||||
)
|
||||
target_link_options(${EXECUTABLE_NAME} PRIVATE -fsanitize=address,undefined)
|
||||
target_compile_options(${EXECUTABLE_NAME} PRIVATE
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wpedantic
|
||||
-Wshadow
|
||||
-Wconversion
|
||||
-Wsign-conversion
|
||||
-Wuninitialized
|
||||
-Wunused
|
||||
-Werror=return-type
|
||||
-fsanitize=address,undefined
|
||||
-g
|
||||
)
|
||||
target_link_options(${EXECUTABLE_NAME} PRIVATE -fsanitize=address,undefined)
|
||||
endif()
|
||||
|
||||
# Optionally, enable testing
|
||||
# enable_testing()
|
||||
# add_subdirectory(tests)
|
||||
# add_subdirectory(tests)
|
||||
|
||||
Reference in New Issue
Block a user