Last active
January 22, 2020 14:33
-
-
Save rubenwardy/ca265e7405952b6031f5 to your computer and use it in GitHub Desktop.
Create CMakeLists
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# I recommend that you install it and run it: | |
# $ sudo cp init_cmake.py /usr/bin | |
# $ init_cmake | |
import os | |
print("Initialise CMAKE by rubenwardy") | |
project_name = raw_input("Project name: ") | |
res = """# Set up project | |
cmake_minimum_required(VERSION 2.6) | |
project(""" + project_name +""") | |
# Source files | |
set(PROJECT_SRC | |
""" | |
def doDir(dir): | |
ret = "" | |
for file in os.listdir(dir + "."): | |
if file.endswith(".cpp"): | |
ret = ret + "\t" + dir + file + "\n" | |
elif os.path.isdir(dir + file) and dir is not None and file is not None: | |
ret = ret + doDir(dir + file + "/") | |
return ret | |
res = res + doDir("") + """) | |
add_executable(${PROJECT_NAME} ${PROJECT_SRC}) | |
file(MAKE_DIRECTORY "bin") | |
set_target_properties(${PROJECT_NAME} | |
PROPERTIES | |
OUTPUT_NAME bin/""" + project_name + """) | |
# Install DLLs | |
install (TARGETS ${PROJECT_NAME} DESTINATION bin) | |
""" | |
fo = open("CMakeLists.txt", "w") | |
fo.write(res) | |
fo.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment