Abhishek Jha
Abhishek Jha

Reputation: 61

CMake cannot find header file near the source one

I don't want to install sqlite globally in my system, so I have downloaded the sqlite3 files from https://www.sqlite.org/2018/sqlite-amalgamation-3240000.zip and have copied sqlite3.c and sqlite3.h into the project folder.

CMakeLists.txt:

cmake_minimum_required(VERSION 3.10)
project(learn_cpp)

set(CMAKE_CXX_STANDARD 11)

add_executable(learn_cpp main.cpp)

main.cpp :

#include <iostream>
#include "sqlite3.h"

int main() {

    return 0;
}

I am not getting any of the functions from sqlite3.h as suggestion in the CLion IDE.

Upvotes: 0

Views: 431

Answers (1)

Tsyvarev
Tsyvarev

Reputation: 66061

By default, CMake doesn't search headers files in the current directory. For enable this behaviour, set CMAKE_INCLUDE_CURRENT_DIR variable:

set(CMAKE_INCLUDE_CURRENT_DIR ON)

add_executable(learn_cpp main.cpp ...)

Upvotes: 2

Related Questions