enhancement(cmake): remove all mentions of "dirs" variable

This commit is contained in:
Jérôme BOULMIER 2019-06-11 20:02:27 -04:00 committed by Patrick Ziegler
parent cb47512871
commit b143e43491
4 changed files with 19 additions and 12 deletions

View File

@ -117,4 +117,17 @@ function(checklib flag type pkg)
endif() endif()
endfunction() endfunction()
function(get_include_dirs output)
get_filename_component(generated_sources_dir ${CMAKE_BINARY_DIR}/generated-sources ABSOLUTE)
get_filename_component(include_dir ${CMAKE_SOURCE_DIR}/include ABSOLUTE)
set(${output} ${include_dir} ${generated_sources_dir} PARENT_SCOPE)
endfunction()
function(get_sources_dirs output)
get_filename_component(src_dir ${CMAKE_SOURCE_DIR}/src ABSOLUTE)
set(${output} ${src_dir} PARENT_SCOPE)
endfunction()
# }}} # }}}

View File

@ -2,8 +2,6 @@
# Generate settings.hpp # Generate settings.hpp
# #
list(APPEND dirs ${CMAKE_CURRENT_LIST_DIR})
if(WITH_XRANDR) if(WITH_XRANDR)
list(APPEND XPP_EXTENSION_LIST xpp::randr::extension) list(APPEND XPP_EXTENSION_LIST xpp::randr::extension)
endif() endif()
@ -20,6 +18,4 @@ configure_file(
${CMAKE_BINARY_DIR}/generated-sources/settings.hpp ${CMAKE_BINARY_DIR}/generated-sources/settings.hpp
ESCAPE_QUOTES) ESCAPE_QUOTES)
list(APPEND dirs ${CMAKE_BINARY_DIR}/generated-sources/)
set(APP_VERSION ${APP_VERSION} PARENT_SCOPE) set(APP_VERSION ${APP_VERSION} PARENT_SCOPE)
set(dirs ${dirs} PARENT_SCOPE)

View File

@ -4,9 +4,8 @@
# Source tree {{{ # Source tree {{{
get_filename_component(generated_sources_dir ${CMAKE_BINARY_DIR}/generated-sources ABSOLUTE) get_include_dirs(includes_dir)
get_filename_component(include_dir ${CMAKE_SOURCE_DIR}/include ABSOLUTE) get_sources_dirs(src_dir)
get_filename_component(src_dir ${CMAKE_CURRENT_SOURCE_DIR} ABSOLUTE)
set(ALSA_SOURCES set(ALSA_SOURCES
${src_dir}/adapters/alsa/control.cpp ${src_dir}/adapters/alsa/control.cpp
@ -135,7 +134,7 @@ set(POLY_SOURCES
# Target: polybar {{{ # Target: polybar {{{
add_library(poly STATIC ${POLY_SOURCES}) add_library(poly STATIC ${POLY_SOURCES})
target_include_directories(poly PUBLIC ${include_dir} ${generated_sources_dir}) target_include_directories(poly PUBLIC ${includes_dir})
target_link_libraries(poly PUBLIC target_link_libraries(poly PUBLIC
Threads::Threads Threads::Threads
Cairo::CairoFC Cairo::CairoFC
@ -176,7 +175,7 @@ if(BUILD_IPC_MSG)
utils/env.cpp utils/env.cpp
utils/file.cpp utils/file.cpp
utils/string.cpp) utils/string.cpp)
target_include_directories(polybar-msg PRIVATE ${dirs}) target_include_directories(polybar-msg PRIVATE ${includes_dir})
target_compile_options(polybar-msg PUBLIC $<$<CXX_COMPILER_ID:GNU>:$<$<CONFIG:MinSizeRel>:-flto>>) target_compile_options(polybar-msg PUBLIC $<$<CXX_COMPILER_ID:GNU>:$<$<CONFIG:MinSizeRel>:-flto>>)
install(TARGETS polybar-msg install(TARGETS polybar-msg

View File

@ -1,6 +1,3 @@
include_directories(${dirs})
include_directories(${CMAKE_CURRENT_LIST_DIR})
# Download and unpack googletest at configure time {{{ # Download and unpack googletest at configure time {{{
configure_file( configure_file(
CMakeLists.txt.in CMakeLists.txt.in
@ -39,6 +36,8 @@ function(add_unit_test source_file)
set(name "unit_test.${testname}") set(name "unit_test.${testname}")
add_executable(${name} unit_tests/${source_file}.cpp) add_executable(${name} unit_tests/${source_file}.cpp)
get_include_dirs(includes_dir)
target_include_directories(${name} PRIVATE ${includes_dir} ${CMAKE_CURRENT_LIST_DIR})
# Link against gmock (this automatically links against gtest) # Link against gmock (this automatically links against gtest)
target_link_libraries(${name} poly gmock_main) target_link_libraries(${name} poly gmock_main)