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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
#!/usr/bin/env ruby
# simple script to generate CMakeLists.txt for wengophone libs
#
# usage: generate_lib_file
# then you will be prompted to enter the required parameters
#
#####################################################################
#
# Copyright (c) 2006 Andreas Schneider <asn@cryptomilk.org>
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
print("Name of project: ")
project=gets.chomp
printf("\n")
print("Other projects to include (e.g. \"owutil tinyxml\", leave emtpy to skip): ")
otherprojects=gets.chomp
printf("\n")
print("Definitions (leave empty to skip): ")
definitions=gets.chomp
cmakePublicIncDirName = project.upcase+"_PUBLIC_INCLUDE_DIRS"
cmakePrivateIncDirName = project.upcase+"_PRIVATE_INCLUDE_DIRS"
cmakeLibName = project.upcase+"_LIBRARY"
cmakeLibNames = project.upcase+"_LINK_LIBRARIES"
cmakePublicDefsName = project.upcase+"_PUBLIC_DEFINITIONS"
cmakePrivateDefsName = project.upcase+"_PRIVATE_DEFINITIONS"
file=File.new("CMakeLists.txt", "w+")
file.printf("project(#{project})\n")
file.printf("\n")
file.printf("# needed include directories to build #{project}\n")
file.printf("# saves the variable in internal cache for later use\n")
file.printf("set(#{cmakePublicIncDirName}\n")
file.printf(" ${CMAKE_CURRENT_SOURCE_DIR}\n")
file.printf(" ${CMAKE_CURRENT_SOURCE_DIR}/include\n")
file.printf(" CACHE INTERNAL \"#{project} public include directories\"\n")
file.printf(")\n")
file.printf("\n")
file.printf("set(#{cmakePrivateIncDirName}\n")
otherprojects.split(" ").each do |otherproject|
file.printf(" ${#{otherproject.upcase}_PUBLIC_INCLUDE_DIRS}\n")
end
file.printf(" ${CMAKE_CURRENT_BINARY_DIR}\n")
file.printf(")\n")
file.printf("\n")
file.printf("set(#{cmakeLibName}\n")
file.printf(" #{project}\n")
file.printf(" CACHE INTERNAL \"#{project} library\"\n")
file.printf(")\n")
file.printf("\n")
file.printf("# #{project} lib and dependencies\n")
file.printf("set(#{cmakeLibNames}\n")
file.printf(" #{cmakeLibName}\n")
otherprojects.split(" ").each do |otherproject|
file.printf(" ${#{otherproject.upcase}_LIBRARIES}\n")
end
file.printf(")\n")
file.printf("\n")
if not definitions.empty?
file.printf("set(#{cmakePublicDefsName}\n")
file.printf(" #{definitions}\n")
file.printf(" CACHE INTERNAL \"#{project} public definitions\"\n")
file.printf(")\n")
file.printf("\n")
file.printf("set(#{cmakePrivateDefsName}\n")
file.printf(" #{definitions}\n")
file.printf(")\n")
file.printf("\n")
end
file.printf("set(#{project}_SRCS\n")
file.printf(" files.c\n")
file.printf(")\n")
file.printf("\n")
file.printf("include_directories(\n")
file.printf(" ${#{cmakePublicIncDirName}}\n")
file.printf(" ${#{cmakePrivateIncDirName}}\n")
file.printf(")\n")
file.printf("\n")
if not definitions.empty?
file.printf("add_definitions(\n")
file.printf(" ${#{cmakePublicDefsName}}\n")
file.printf(" ${#{cmakePrivateDefsName}}\n")
file.printf(")\n")
file.printf("\n")
end
file.printf("\n")
file.printf("add_library(${#{cmakeLibName}} STATIC ${#{project}_SRCS})\n")
file.printf("\n")
file.printf("target_link_libraries(${#{cmakeLibNames}})\n")
file.printf("\n")
printf("Generated CMakeLists.txt for #{project}\n")
|