Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed typos, bumped Cmake Requirements to 3.24, switched to "project(" #4

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions auto2cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(self, directory):
self.directory = directory # The directory where this can be found
self.contained_libraries_content = [] # All the content of the libraries that are created in here
self.libraries = [] # All the libraries that are created by this file
self.extra_content = "" # Extra stuff such as add_subdriectory
self.extra_content = "" # Extra stuff such as add_subdirectory

########################################################################################################################
# Whether a target is a library (noinst_LIBRARIES) or an application (bin_PROGRAMS)
Expand Down Expand Up @@ -127,7 +127,7 @@ def __init__(self, name, directory):


########################################################################################################################
# represents an option that will go in the CMakeLists.txt and also in the generated header if has a define
# represents an option that will go in the CMakeLists.txt and also in the generated header if it has a define
########################################################################################################################
class Option:

Expand Down Expand Up @@ -652,7 +652,7 @@ def process_makefile_am(file):


########################################################################################################################
# processes all the libraries, creates the requested CMakeFile list ofthe application
# processes all the libraries, creates the requested CMakeFile list of the application
########################################################################################################################
def process_libraries():
for library in libraries:
Expand Down Expand Up @@ -909,8 +909,8 @@ def filelist_to_string(elements, source_directory, spacecount = 4):
if os.path.isfile(source_directory + "/" + file):
filelist += "\n" +" " * spacecount + "${CMAKE_CURRENT_SOURCE_DIR}/" + file
else:
filelist += "\n#" +" " * spacecount + "${CMAKE_CURRENT_SOURCE_DIR}/" + file + " # File not found. Fix manually"
warning("WARNING!!! The file: " + source_directory + "/" + file + " is present in the Makefile.am but cannot be found in the filesystem")
filelist += "\n#" +" " * spacecount + "${CMAKE_CURRENT_SOURCE_DIR}/" + file + " # File not found. Fix manually."
warning("WARNING!!! The file: " + source_directory + "/" + file + " is present in the Makefile.am but cannot be found in the filesystem.")
return filelist

########################################################################################################################
Expand Down Expand Up @@ -989,7 +989,7 @@ def process_configure_ac(fname):
# Add it in there
config_ac_variables[varname]["value"].append(var_value)

# And finally see if this is somethign we can work with
# And finally see if this is something we can work with
method = processable_line(current_line)
if method:
full_line = ""
Expand Down Expand Up @@ -1051,7 +1051,7 @@ def process_configure_ac(fname):
########################################################################################################################
def generate_default_cmake(req_dir):
projname = req_dir.split("/")[-1] + ")\n"
sources = "set (project "
sources = "project("
fritzone marked this conversation as resolved.
Show resolved Hide resolved
sources += projname
sources += ")\nset(${project}_SOURCES\n"
files = glob.glob(req_dir + "/*.c*")
Expand All @@ -1064,8 +1064,12 @@ def generate_default_cmake(req_dir):
sources += ")\n"

r_cmake_file = open(req_dir + "/CMakeLists.txt", "w")
r_cmake_file.write("cmake_minimum_required(VERSION 2.8)\n")
r_cmake_file.write("cmake_minimum_required(VERSION 3.24)\n")
fritzone marked this conversation as resolved.
Show resolved Hide resolved
r_cmake_file.write(sources)
# r_cmake_file.write( VERSION 1.0.0.0)
fritzone marked this conversation as resolved.
Show resolved Hide resolved
# r_cmake_file.write( DESCRIPTION "Your description here")
# r_cmake_file.write( HOMEPAGE_URL "https://www.example.com")
# r_cmake_file.write( LANGUAGES ")\n\n",)
r_cmake_file.write("add_library(${project} STATIC ${${project}_SOURCES} )")
r_cmake_file.close()

Expand Down Expand Up @@ -1116,11 +1120,11 @@ def create_cmakefile(path, cpps, headers, module):

f = open(pjoin(path,"CMakeLists.txt"), "w+")

f.write("cmake_minimum_required(VERSION 2.8)\n")
f.write("cmake_minimum_required(VERSION 3.24)\n")
if full_module:
f.write("set (project " + full_module + ")\n\n")
f.write("project(" + full_module + ")\n\n")
else:
f.write("set (project " + module + ")\n\n")
f.write("project(" + module + ")\n\n")
full_module = module

if cpps:
Expand Down Expand Up @@ -1354,7 +1358,7 @@ def convert_qmake_project(dir, fn):

cmake_file = open(dir + "/CMakeLists.txt", "w")
cmake_file.write("# Autogenerated by auto2cmake on {0}\n\n".format(time.strftime("%Y-%m-%d %H:%M:%S")))
cmake_file.write("cmake_minimum_required(VERSION 2.8)\n\n")
cmake_file.write("cmake_minimum_required(VERSION 3.24)\n\n")
cmake_file.write("set(project \"" + qmake_target_name + "\")\n")
cmake_file.write("project (${project})\n\n")

Expand Down Expand Up @@ -1512,7 +1516,7 @@ def convert():
format(time.strftime("%Y-%m-%d %H:%M:%S")))

# let's not be very cmake hungry
cmake_file.write("cmake_minimum_required(VERSION 2.8)\n")
cmake_file.write("cmake_minimum_required(VERSION 3.24)\n")

sorted_options = sorted(options.items(), key=lambda x: x[1].get_name(), reverse=False)
for option in sorted_options:
Expand Down Expand Up @@ -1559,7 +1563,7 @@ def convert():

cmake_file.write("\n")
cmake_file.write("## !!! WARNING These are the defines that were defined regardless of an option.\n"
"## !!! Or the script couldn't match them. Match them accordingly, delete them or keep them\n")
"## !!! Or the script couldn't match them. Match them accordingly, delete them or keep them.\n")

# Now put out all the temp_defines that are still not used
for temp_define_name in temp_defines:
Expand Down Expand Up @@ -1612,7 +1616,7 @@ def convert():
# and generate in there manually, after removing the entries which are in the do not include list
final_list = [x for x in required_directories if not should_exclude(x)]

warning("WARNING!!! Creating default CMakeLists.txt in the directories below. Don't forget to fix these later")
warning("WARNING!!! Creating default CMakeLists.txt in the directories below. Don't forget to fix these later!")
for req_dir in final_list:
warning("Default CMakeLists.txt in:", req_dir)
generate_default_cmake(req_dir)
Expand Down