Add CMakeLists.txt#69
Conversation
|
Thanks for adding CMake support. I found a couple of issues that should be addressed before this can reliably build on downstream projects, especially on Windows/MSVC.
CMake only creates one target here; in practice this generates a shared library with the VS generator. The project does not define export macros or enable
The public headers ( |
|
Also, I see that your |
| set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
| set(CMAKE_AUTOMOC ON) | ||
|
|
||
| find_package(Qt6 REQUIRED COMPONENTS |
There was a problem hiding this comment.
| find_package(Qt6 REQUIRED COMPONENTS | |
| find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core) | |
| find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS |
Adaptive Qt version
| else() | ||
| message(STATUS "Using BUNDLED QuickJS") | ||
|
|
||
| add_subdirectory(quickjs) |
There was a problem hiding this comment.
It doesn’t seem necessary to include the entire QuickJS library, as we only need a few of its files. If we include the whole thing, it looks as though it will compile things like qjs by default, which we don’t need.
| Qt6::Core | ||
| ) | ||
|
|
||
| target_compile_options(${PROJECT_NAME} PRIVATE -fpermissive -Wno-narrowing) |
There was a problem hiding this comment.
| target_compile_options(${PROJECT_NAME} PRIVATE -fpermissive -Wno-narrowing) | |
| if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") | |
| target_compile_options(${PROJECT_NAME} PRIVATE -fpermissive -Wno-narrowing) | |
| endif() |
-fpermissive and -Wno-narrowing are GCC/Clang-specific flags; they will cause errors in MSVC. A compiler check is required.
|
|
||
| src/QScriptEngine/build | ||
|
|
||
| src/QQScriptDemo/build |
There was a problem hiding this comment.
| src/QScriptEngine/build | |
| src/QQScriptDemo/build |
The .gitignore file already contains *build*/, so the two new entries are actually redundant (as they are already covered by the wildcard).
| # ------------------------------------------------- | ||
| # Includes | ||
| # ------------------------------------------------- | ||
| include_directories( | ||
| ${CMAKE_CURRENT_SOURCE_DIR} | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/scriptEngine/include | ||
| ) |
There was a problem hiding this comment.
| # ------------------------------------------------- | |
| # Includes | |
| # ------------------------------------------------- | |
| include_directories( | |
| ${CMAKE_CURRENT_SOURCE_DIR} | |
| ${CMAKE_CURRENT_SOURCE_DIR}/scriptEngine/include | |
| ) |
Since target_include_directories(...) already handles the same path, the global include_directories variable will pollute the parent project’s scope and should be removed.
| # ------------------------------------------------- | ||
| # Library target | ||
| # ------------------------------------------------- | ||
| add_library(${PROJECT_NAME} STATIC SHARED |
There was a problem hiding this comment.
STATIC SHARED is an invalid parameter; CMake will return an error immediately. You should either specify a single type or omit the type entirely (allowing the user to control this via BUILD_SHARED_LIBS).
Add CMakeLists to use with cmake