CMakeLists.txt | Help compile the c++source code

There are source codes, as I understand it, in C++ https://github.com/fossephate/JoyCon-Driver

I want to build an "exe-shnik" with a few changes in the code, but I understand C++ at the level of "1++ = 2". That is, nothing.

The project seems to have been compiled by the author in visual studio. I cloned it in CLion from JetBrains, but here's the problem - you need some file CMakeLists.txt. The file I created:

cmake_minimum_required(VERSION 3.5)
project(test)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set(LIBRARY_FILES "libs")
file(GLOB_RECURSE SRC_UI
        "${LIBRARY_FILES}/*.cpp"
        "${LIBRARY_FILES}/*.h"
        )
file(GLOB_RECURSE SRC_IMPORT
        "${LIBRARY_FILES}/*.cpp"
        "${LIBRARY_FILES}/*.h"
        )

add_library(hidapi ${SRC_UI} ${SRC_IMPORT})

set(SOURCE_FILES "src/main.cpp")

add_executable(test ${SOURCE_FILES})

I created a file, but after the build, the program does not see it libraries, probably in VisualStudio "dependencies" (plug-in libraries) were specified in some other way. If anyone understands, please help me, how to fill in this file so that the program starts?

Author: Goldus, 2020-10-08

1 answers

I found what I was looking for - a simple python script helped me: https://github.com/gns333/Vcxproj2CMake

Converts studio files (.vcxproj) to a file CMakeLists.txt.

Honestly, I still don't understand how it works and it didn't solve my general problem with the lack of libraries, but the compiler pulled up the libraries from the /lib folder, so I think that this answer has the right to live.

P.S. The author did not add any obvious ways to run the script, as an option, at the end the file can be thrown something like:

if __name__ == "__main__":
    import argparse
    parser = argparse.ArgumentParser(description='Select vcxproj file!')
    parser.add_argument('source_file', help="Link to source file")
    args = parser.parse_args()
    source_file = args.source_file
    filename = source_file.split("/")[-1]
    project_dir = source_file.replace(filename, "")
    generate(vcxprojfile=source_file, vcxprojDir=project_dir)
 0
Author: Goldus, 2020-10-09 16:29:13