Skip to content

Commit

Permalink
Add cpcfg target
Browse files Browse the repository at this point in the history
  • Loading branch information
eodus committed May 23, 2017
1 parent eb98ca1 commit 76d6996
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ prefix?="/usr/local"

all: igrec

cpcfg:
mkdir -p build/tmp
cd build/tmp && cmake ../../configs -DCMAKE_OVERWRITE_CONFIGS=true
rm -r build/tmp

cmake:
mkdir -p build/release
cd build/release && cmake ../.. -DCMAKE_BUILD_TYPE="${build_type}" -DCMAKE_INSTALL_PREFIX=${prefix} -Wno-dev
Expand Down
31 changes: 21 additions & 10 deletions configs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
project(configs)
cmake_minimum_required(VERSION 2.8)

file(GLOB config_templates "*/*.template")
foreach(config_template ${config_templates})
# Remove extention
STRING(REGEX REPLACE "\\.template$" "" config ${config_template})
if(NOT EXISTS "${config}")
configure_file("${config_template}"
"${config}"
@ONLY)
endif()
endforeach()
function(cpcfg overwrite)
if (${overwrite})
MESSAGE("Configs will be overwritten")
endif()
file(GLOB config_templates "*/*.template")
foreach(config_template ${config_templates})
# Remove extention
STRING(REGEX REPLACE "\\.template$" "" config ${config_template})
if(NOT EXISTS "${config}" OR ${overwrite})
configure_file("${config_template}"
"${config}"
@ONLY)
endif()
endforeach()
endfunction(cpcfg)

if (NOT CMAKE_OVERWRITE_CONFIGS)
SET(CMAKE_OVERWRITE_CONFIGS "FALSE")
endif()

cpcfg(${CMAKE_OVERWRITE_CONFIGS})

0 comments on commit 76d6996

Please sign in to comment.