source: pacpusframework/trunk/src/_NewComponent/CMakeLists.txt@ 196

Last change on this file since 196 was 147, checked in by Marek Kurdej, 11 years ago

Added: scripts to create new component.

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