Skip to content

cmake include path still not working #240

@echoface

Description

@echoface

cmake project still can't export its include dir;

cmake_minimum_required(VERSION 3.14 FATAL_ERROR)

project(llhttpexe VERSION 0.2.1 LANGUAGES C CXX)

# for generate ycm complete database
SET(CMAKE_CXX_STANDARD 14)
SET(CMAKE_EXPORT_COMPILE_COMMANDS ON)

include(FetchContent)
FetchContent_Declare(llhttp URL "https://github.com/nodejs/llhttp/archive/refs/tags/release/v8.1.0.tar.gz")
FetchContent_MakeAvailable(llhttp)

add_executable(main
    main.cc)

target_link_libraries(main
    llhttp_shared)    
#include "llhttp.h"
#include "stdio.h"
#include "string.h"

int handle_on_message_complete(llhttp_t *parser) {
  fprintf(stdout, "Message completed!\n");
  return 0;
}

int main() {
  llhttp_t parser;
  llhttp_settings_t settings;

  int request_len = strlen(request);

  enum llhttp_errno err = llhttp_execute(&parser, request, request_len);
  if (err == HPE_OK) {
    fprintf(stdout, "Successfully parsed!\n");
  } else {
    fprintf(stderr, "Parse error: %s %s\n", llhttp_errno_name(err), parser.reason);
  }
}

according to cmake generated output, no correct -Ixxxx/include/path to main.cc compiler command

{
  "directory": "/home/echoface/code/llhttpexe/build",
  "command": "/usr/bin/c++   -O2 -g -DNDEBUG -std=gnu++14 -o CMakeFiles/main.dir/main.cc.o -c /xxxxx/llhttpexe/main.cc",
  "file": "/xxxx/llhttpexe/main.cc"
},

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions