Simple cmake example with working ccls
This commit is contained in:
		
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
.ccls-cache
 | 
			
		||||
compile_commands.json
 | 
			
		||||
build
 | 
			
		||||
							
								
								
									
										16
									
								
								CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,16 @@
 | 
			
		||||
# Specify the minimum version of CMake required
 | 
			
		||||
cmake_minimum_required(VERSION 3.10)
 | 
			
		||||
 | 
			
		||||
# Set the project name and version
 | 
			
		||||
project(MyProject VERSION 1.0)
 | 
			
		||||
 | 
			
		||||
# Specify the C++ standard
 | 
			
		||||
set(CMAKE_CXX_STANDARD 17)
 | 
			
		||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
 | 
			
		||||
 | 
			
		||||
# Include the header files
 | 
			
		||||
include_directories(include)
 | 
			
		||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
 | 
			
		||||
 | 
			
		||||
# Add the executable
 | 
			
		||||
add_executable(MyProject src/main.cpp src/HelloWorld.cpp)
 | 
			
		||||
							
								
								
									
										11
									
								
								include/HelloWorld.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								include/HelloWorld.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
#ifndef HELLOWORLD_H
 | 
			
		||||
#define HELLOWORLD_H
 | 
			
		||||
 | 
			
		||||
#include <string>
 | 
			
		||||
 | 
			
		||||
class HelloWorld {
 | 
			
		||||
public:
 | 
			
		||||
  void printMessage(const std::string &message);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // HELLOWORLD_H
 | 
			
		||||
							
								
								
									
										13
									
								
								justfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								justfile
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,13 @@
 | 
			
		||||
default: run
 | 
			
		||||
 | 
			
		||||
build:
 | 
			
		||||
	mkdir -p build && cd build && cmake .. && cmake --build .
 | 
			
		||||
 | 
			
		||||
run: build
 | 
			
		||||
	cd build && ./MyProject
 | 
			
		||||
 | 
			
		||||
ccls:
 | 
			
		||||
	mkdir -p build && cd build && cmake .. && cd .. && ln -s build/compile_commands.json .
 | 
			
		||||
 | 
			
		||||
clean:
 | 
			
		||||
	rm -rf build && rm compile_commands.json
 | 
			
		||||
							
								
								
									
										6
									
								
								src/HelloWorld.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								src/HelloWorld.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,6 @@
 | 
			
		||||
#include "HelloWorld.h"
 | 
			
		||||
#include <iostream>
 | 
			
		||||
 | 
			
		||||
void HelloWorld::printMessage(const std::string &message) {
 | 
			
		||||
  std::cout << message << std::endl;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										7
									
								
								src/main.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src/main.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
			
		||||
#include "HelloWorld.h"
 | 
			
		||||
 | 
			
		||||
int main() {
 | 
			
		||||
  HelloWorld hello;
 | 
			
		||||
  hello.printMessage("Hello, World!");
 | 
			
		||||
  return 0;
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user