This commit is contained in:
Yuxuan Shui 2019-10-21 22:40:29 +01:00
parent f227e6c8c7
commit 11f12cbafc
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
5 changed files with 133 additions and 0 deletions

3
.cmake-format.yaml Normal file
View File

@ -0,0 +1,3 @@
dangle_parens: True
line_width: 90
tab_size: 2

66
CMakeLists.txt Normal file
View File

@ -0,0 +1,66 @@
cmake_minimum_required(VERSION 3.5)
project(
picom
LANGUAGES C
VERSION 7
)
set(VER "v${PROJECT_VERSION}")
find_program(GIT git)
if(GIT)
execute_process(
COMMAND ${GIT} rev-parse --short=5 HEAD
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE GIT_RETURN
OUTPUT_VARIABLE GIT_VER
)
if(GIT_RETURN EQUAL 0)
string(STRIP ${GIT_VER} GIT_VER)
set(VER "vgit-${GIT_VER}")
endif()
endif()
message(STATUS "Using version number: ${VER}")
add_definitions(-DPICOM_VERSION=${VER})
add_definitions(-D_GNU_SOURCE)
option(SANITIZE "Build picom with sanitizers")
include(CheckCCompilerFlag)
include(CheckIncludeFile)
if(SANITIZE)
set(SANITIZERS address undefined)
foreach(CURRENT_TEST integer nullability)
check_c_compiler_flag("-fsanitize=${CURRENT_TEST}" "HAS_${CURRENT_TEST}")
if(HAS_${CURRENT_TEST})
list(APPEND SANITIZERS ${CURRENT_TEST})
endif()
endforeach()
string(JOIN "," SANITIZERS_FLAG ${SANITIZERS})
string(APPEND CMAKE_C_FLAGS " -fsanitize=${SANITIZERS_FLAG}")
message(STATUS "Enabled sanitizers: ${SANITIZERS_FLAG}")
foreach(CURRENT_TEST unsigned-integer-overflow)
check_c_compiler_flag("-fno-sanitize=${CURRENT_TEST}" "HAS_DISABLE_${CURRENT_TEST}")
if(HAS_DISABLE_${CURRENT_TEST})
list(APPEND DISABLED_SANITIZERS ${CURRENT_TEST})
endif()
endforeach()
string(JOIN "," DISABLED_SANITIZERS_FLAG ${DISABLED_SANITIZERS})
string(APPEND CMAKE_C_FLAGS " -fno-sanitize=${DISABLED_SANITIZERS_FLAG}")
message(STATUS "Disabled sanitizers: ${DISABLED_SANITIZERS_FLAG}")
endif()
option(MODULARIZE "Build picom using clang's -fmodules feature")
check_include_file(stdc-predef.h HAS_STDC_PREDEF_H)
if(HAS_STDC_PREDEF_H)
add_definitions(-DHAS_STDC_PREDEF_H)
endif()
add_subdirectory("subprojects/test.h")
add_subdirectory("src")
add_subdirectory("man")

0
man/CMakeLists.txt Normal file
View File

59
src/CMakeLists.txt Normal file
View File

@ -0,0 +1,59 @@
set(SRC
compton.c
win.c
c2.c
x.c
config.c
vsync.c
utils.c
diagnostic.c
string_utils.c
render.c
kernel.c
log.c
options.c
event.c
cache.c
atom.c
)
include(FindPkgConfig)
add_library(libev UNKNOWN IMPORTED)
pkg_check_modules(LIBEV_PC libev)
if(LIBEV_PC_FOUND)
link_directories(${LIBEV_LIBRARY_DIRS})
endif()
add_executable(picom ${SRC})
target_link_libraries(picom PRIVATE test.h)
if(MODULARIZE)
check_c_compiler_flag("-fmodules" HAS_MODULARIZE)
if(NOT HAS_MODULARIZE)
message(SEND_ERROR "Compiler doesn't support -fmodules")
endif()
add_custom_target(modulemap DEPENDS compton.modulemap)
add_dependencies(picom modulemap)
target_compile_options(
picom PRIVATE -fmodules
-fmodule-map-file=${CMAKE_CURRENT_SOURCE_DIR}/compton.modulemap
)
endif()
check_include_file(uthash.h HAS_UTHASH)
if(NOT HAS_UTHASH)
message(SEND_ERROR "uthash not found")
endif()
if(NOT LIBEV_PC_FOUND)
find_library(LIBEV ev)
if(NOT LIBEV)
message(SEND_ERROR "libev not found")
else()
message(STATUS "Looking for libev - found")
target_link_libraries(picom PRIVATE ev)
endif()
else()
target_link_libraries(picom PRIVATE ${LIBEV_LIBRARIES})
endif()

View File

@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.0)
project(test.h C)
add_library(test.h INTERFACE)
target_include_directories(test.h INTERFACE .)