forked from ahoarau/meka-cmake-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
42 lines (34 loc) · 1.42 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
cmake_minimum_required(VERSION 2.5)
project(meka_cmake_modules)
# Overwrite option
option(OVERWRITE "Overwrite existing files in ${CMAKE_ROOT}/Modules" OFF)
# Printing a warning
if(${OVERWRITE})
message("-- OVERWRITE Option is ON")
endif()
# Searching for all the modules
file(GLOB all_find_modules "${CMAKE_CURRENT_SOURCE_DIR}/Modules/*.cmake")
## Printing
#foreach(find_module ${all_find_modules})
# message("-- Cmake module found : ${find_module}")
#endforeach()
# Installing them in /usr/local/lib/cmake/xxx/Findxxx.cmake
# According to http://www.cmake.org/cmake/help/v2.8.8/cmake.html#command:find_package
foreach(find_module ${all_find_modules})
get_filename_component(Findname ${find_module} NAME_WE )
get_filename_component(Findname_s ${find_module} NAME )
string(REPLACE "Find" "" name ${Findname})
if(EXISTS "${CMAKE_ROOT}/Modules/${Findname_s}")
message( "${Findname_s} already exists in ${CMAKE_ROOT}/Modules !")
if(${OVERWRITE})
message("-- ${Findname_s} will be installed in /usr/local/lib/cmake/${name}/ (OVERWRITTING)")
install(FILES ${find_module} DESTINATION ${CMAKE_ROOT}/Modules)
else(${OVERWRITE})
message("Use -DOVERWRITE=1 if you want to overwrite those modules (use at your own risks")
endif(${OVERWRITE})
else()
message("-- ${Findname_s} will be installed in /usr/local/lib/cmake/${name}/")
install(FILES ${find_module} DESTINATION ${CMAKE_ROOT}/Modules)
endif()
message("")
endforeach()