myproject/
| - CMakeLists.txt <= 1. Top-level CMake configuration. add_subdirectory "externals" and "src" in that order.
| - src/
| - | - CMakeLists.txt <= 2. add_executable for myproject
| - | - ...
| - | - main.cpp
| - externals/
| - | - CMakeLists.txt <= 3. load all externals by calling add_subdirectory for each subdirectories
| - | - cef/
| - | - | - CMakeLists.txt <= 4. add_subdirectory(win32) on win32 archi, win64 on x64 windows archi, etc...
| - | - | - win32/ <= cef_binary_3.3325.1750.gaabe4c4_windows32.tar.bz2 uncompressed here
| - | - | - | - cmake/
| - | - | - | - Debug/
| - | - | - | - include/
| - | - | - | - libcef_dll/
| - | - | - | - ...
| - | - | - | - CMakeLists.txt <= Not used
| - | - | - | - LICENSE.txt
| - | - | - | - README.md
The main CMakeLists.txt (i.e. 1) is in charge of adding externals libraries (in externals folder) and sources (form src folder)
- Code: Select all
cmake_minimum_required(VERSION 3.5)
# Add externals libraries
add_subdirectory("externals")
# Add Src
add_subdirectory("src")
The externals/cef/CMakeLists.txt is in charge of adding "libcef_lib" and "libcef_dll_wrapper" libraries:
- Code: Select all
# Add CEF
set(CEF_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/win32")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CEF_ROOT}/cmake")
find_package(CEF REQUIRED)
# Logical target used to link the libcef library.
ADD_LOGICAL_TARGET(libcef_lib ${CEF_LIB_DEBUG} ${CEF_LIB_RELEASE})
SET_EXECUTABLE_TARGET_PROPERTIES(libcef_lib)
# Determine the target output directory.
SET_CEF_TARGET_OUT_DIR()
# Include the libcef_dll_wrapper target.
# Comes from the libcef_dll/CMakeLists.txt file in the binary distribution
# directory.
add_subdirectory(${CEF_LIBCEF_DLL_WRAPPER_PATH} libcef_dll_wrapper)
# Display configuration settings.
PRINT_CEF_CONFIG()
The src/CMakeLists.txt (i.e. 2) is in charge of declaring the executable "myproject" and linking against "libcef_lib", "libcef_dll_wrapper" and cef standard libs. (inspired by cefsimple project)
- Code: Select all
project(myproject VERSION 1.0 LANGUAGES CXX)
....
# Executable target.
add_executable(myproject ${MYPROJECT_SRCS})
add_dependencies(myproject libcef_dll_wrapper)
SET_EXECUTABLE_TARGET_PROPERTIES(myproject)
target_link_libraries(myproject libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS})
When I try to generate the solution (Visual Studio .sln file) I got this error:
- Code: Select all
1> CMake Error at externals/cef/win32/cmake/cef_macros.cmake:290 (target_compile_options):
1> target_compile_options may only set INTERFACE properties on IMPORTED
1> targets
1> Call Stack (most recent call first):
1> externals/cef/win32/cmake/cef_macros.cmake(366): (SET_COMMON_TARGET_PROPERTIES)
1> externals/cef/CMakeLists.txt(9): (SET_EXECUTABLE_TARGET_PROPERTIES)
So this error seems to come from the "cef_macros.cmake" file but the mistake must come from my specific usage...
If someone could help me on this...
Thanks