diff --git a/CMakeLists.txt b/CMakeLists.txt index 444649b..dd3847e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.0) project(NameSort C) set(CMAKE_C_STANDARD 11) diff --git a/README.md b/README.md new file mode 100644 index 0000000..0c8d222 --- /dev/null +++ b/README.md @@ -0,0 +1,52 @@ +# NameSort +This program is designed to take as input a txt file containing a list of names, separated by line breaks, and sorts +them first by length and then alphabetically. + +As this program is written in pure C (C11 to be exact) with a CMake build script, you will require a C Compiler and +CMake to build it. The program doesn't, however, rely on any external libraries aside from the C Standard Library +available with all C Compilers, so that is all that is required. + +# Unix Build +If you are on a Unix-based system, your system's cc/gcc compiler should be enough to build the program. Make sure you +have build tools and cmake installed. Create a 'build' directory, cd into it using the shell of your choice, then +invoke cmake, and finally invoke make. + +mkdir build +cd build +cmake ../ +make + +After you have built the program, you can run it from the build directory or move it to a location of your choice. +The program needs the file to sort passed to it. I have included a copy of the 'Sort Me.txt' test file within the +'sandbox' folder of the project, for testing purposes. To test the program on it, simply run the following commands +from within the build directory: + +./NameSort "../sandbox/Sort Me.txt" + +# Windows Build + +If you are on Windows, you will require Visual Studio 2017 or later, as this project +does use CMake and, unless you want to use the CMake custom tools, Visual Studio did not have support for CMake +before this version. + +To build the project, just open Visual Studio, and choose Open->CMake from the file menu. Navigate to the project +folder, and select the CMakeLists.txt file. The project should open in Visual Studio and, after a bit of indexing, +settle. Once indexed, change the run configuration to NameSort. It may initially say "Select Startup Item". + +Once selected, use the Build menu and select "Build". The project should Build successfully. + +Unfortunately, Visual Studio still does not support setting run configurations for Cmake project, so there is no way +to run the program successfully and pass it the file. Instead, you will have to open Command Prompt or Powershell +and run the program the hard way. + +The default configuration will have placed the built exe in the following folder: + +"C:\Users\\CMakeBuilds\\build\x64-Debug (default)" + +Navigate to this folder and open a command prompt/powershell, or navigate to it directly from within the shell. I also +recommend copying the "Sort Me.txt" file into this directory, so you don't have to pass a very long path name to the +program. + +To run the program, it will be almost the same as on Unix: + +./NameSort.exe "./Sort Me.txt" \ No newline at end of file