[147] | 1 | #################################################
|
---|
| 2 | # ___________ ____ ______ __ __ _____ #
|
---|
| 3 | # \____ \__ \ _/ ___\\____ \| | \/ ___/ #
|
---|
| 4 | # | |_> > __ \\ \___| |_> > | /\___ \ #
|
---|
| 5 | # | __(____ /\___ > __/|____//____ > #
|
---|
| 6 | # |__| \/ \/|__| \/ #
|
---|
| 7 | # #
|
---|
| 8 | #################################################
|
---|
| 9 |
|
---|
| 10 | project(PacpusNewComponent)
|
---|
| 11 | cmake_minimum_required(VERSION 2.8)
|
---|
| 12 | if(POLICY CMP0020)
|
---|
| 13 | cmake_policy(SET CMP0020 NEW) # for QT5.1 on windows / not work on linux
|
---|
| 14 | endif()
|
---|
| 15 |
|
---|
| 16 | ################################################################################
|
---|
| 17 | set(PACPUS_COMPONENT_NAME "" CACHE STRING "name of the new component")
|
---|
| 18 |
|
---|
| 19 | if("${PACPUS_COMPONENT_NAME}" STREQUAL "")
|
---|
| 20 | message(FATAL_ERROR "You should set the PACPUS_COMPONENT_NAME variable")
|
---|
| 21 | endif()
|
---|
| 22 |
|
---|
| 23 | ################################################################################
|
---|
| 24 | # set substitution variables
|
---|
| 25 | string(TOUPPER "${PACPUS_COMPONENT_NAME}" PACPUS_COMPONENT_NAME_CAPS)
|
---|
| 26 | if(WIN32)
|
---|
| 27 | set(USERNAME "$ENV{USERNAME}" CACHE STRING "username")
|
---|
| 28 | else()
|
---|
| 29 | set(USERNAME "$ENV{USER}" CACHE STRING "username")
|
---|
| 30 | endif()
|
---|
| 31 | string(TIMESTAMP CURRENT_DATETIME "%Y-%m-%d %H:%M:%S")
|
---|
| 32 |
|
---|
| 33 | ################################################################################
|
---|
| 34 | # create directory for new files
|
---|
| 35 | set(OUTPUT_DIR "../${PACPUS_COMPONENT_NAME}")
|
---|
| 36 | file(MAKE_DIRECTORY "${OUTPUT_DIR}")
|
---|
| 37 |
|
---|
| 38 | # configure files
|
---|
[216] | 39 | configure_file("CMakeLists.txt.in" "${OUTPUT_DIR}/CMakeLists.txt" @ONLY)
|
---|
| 40 | configure_file("NewComponent.h.in" "${OUTPUT_DIR}/${PACPUS_COMPONENT_NAME}.h" @ONLY)
|
---|
| 41 | configure_file("NewComponent.cpp.in" "${OUTPUT_DIR}/${PACPUS_COMPONENT_NAME}.cpp" @ONLY)
|
---|
| 42 | configure_file("NewComponentImpl.h.in" "${OUTPUT_DIR}/${PACPUS_COMPONENT_NAME}Impl.h" @ONLY)
|
---|
| 43 | configure_file("NewComponentImpl.cpp.in" "${OUTPUT_DIR}/${PACPUS_COMPONENT_NAME}Impl.cpp" @ONLY)
|
---|
[147] | 44 |
|
---|
| 45 | ################################################################################
|
---|
| 46 | message(STATUS "New component '${PACPUS_COMPONENT_NAME}' has been created.")
|
---|
| 47 | message(STATUS "Please add line 'add_subdirectory(${PACPUS_COMPONENT_NAME})' to your main CMakeLists.txt file.")
|
---|