I'm trying to build a particular example that came with CGAL but it fails to find BOOST for some reason.
I successfully compiled CGAL itself in a similar manner.
I followed this guide on how to build it on windows.
I'm sure setted up BOOST_ROOT environment variable correctly.
Edit2: I recreated cmake file with given script for Core example as follows.
cd temp
cgal_create_CMakeLists -s delunay
In cmake UI I set Boost_DEBUG=ON and Configure.
I get error as follows (I've edited out irrelevant parts):
cmake-2.8/Modules/FindBoost.cmake:476 ] _boost_TEST_VERSIONS = 1.56.1;/* ... omitted*/
cmake-2.8/Modules/FindBoost.cmake:478 ] Boost_USE_MULTITHREADED = TRUE
cmake-2.8/Modules/FindBoost.cmake:480 ] Boost_USE_STATIC_LIBS = OFF
cmake-2.8/Modules/FindBoost.cmake:482 ] Boost_USE_STATIC_RUNTIME =
cmake-2.8/Modules/FindBoost.cmake:484 ] Boost_ADDITIONAL_VERSIONS = 1.56.1; /*... omitted*/
cmake-2.8/Modules/FindBoost.cmake:486 ] Boost_NO_SYSTEM_PATHS =
cmake-2.8/Modules/FindBoost.cmake:538 ] Declared as CMake or Environmental Variables:
cmake-2.8/Modules/FindBoost.cmake:540 ] BOOST_ROOT =
cmake-2.8/Modules/FindBoost.cmake:542 ] BOOST_INCLUDEDIR =
cmake-2.8/Modules/FindBoost.cmake:544 ] BOOST_LIBRARYDIR =
cmake-2.8/Modules/FindBoost.cmake:546 ] _boost_TEST_VERSIONS = 1.56.1;1.56.0; /*... omitted*/
cmake-2.8/Modules/FindBoost.cmake:639 ] location of version.hpp: D:/dev/boost_1_54_0/boost/version.hpp
cmake-2.8/Modules/FindBoost.cmake:663 ] version.hpp reveals boost 1.54.0
cmake-2.8/Modules/FindBoost.cmake:739 ] guessed _boost_COMPILER = -vc110
cmake-2.8/Modules/FindBoost.cmake:749 ] _boost_MULTITHREADED = -mt
cmake-2.8/Modules/FindBoost.cmake:792 ] _boost_RELEASE_ABI_TAG = -
cmake-2.8/Modules/FindBoost.cmake:794 ] _boost_DEBUG_ABI_TAG = -gd
cmake-2.8/Modules/FindBoost.cmake:842 ] _boost_LIBRARY_SEARCH_DIRS = D:/dev/boost_1_54_0/lib32-msvc-11.0;D:/dev/boost_1_54_0/lib;D:/dev/boost_1_54_0/stage/lib;D:/dev/boost_1_54_0/lib;D:/dev/boost_1_54_0/../lib;D:/dev/boost_1_54_0/stage/lib;PATHS;C:/boost/lib;C:/boost;/sw/local/lib
cmake-2.8/Modules/FindBoost.cmake:1017 ] Boost_FOUND = 1
Boost version: 1.54.0
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
Boost_INCLUDE_DIR (ADVANCED)
used as include directory in directory D:/dev/CGAL-4.3/scripts/temp
Configuring incomplete, errors occurred!
See also "D:/dev/CGAL-4.3/scripts/temp/build/CMakeFiles/CMakeOutput.log".
Core's generated cmake file:
# Created by the script cgal_create_cmake_script_with_options
# This is the CMake script for compiling a set of CGAL applications.
project( delaunay )
cmake_minimum_required(VERSION 2.6.2)
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" VERSION_GREATER 2.6)
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER 2.8.3)
cmake_policy(VERSION 2.8.4)
else()
cmake_policy(VERSION 2.6)
endif()
endif()
set( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true )
if ( COMMAND cmake_policy )
cmake_policy( SET CMP0003 NEW )
endif()
# CGAL and its components
find_package( CGAL QUIET COMPONENTS )
if ( NOT CGAL_FOUND )
message(STATUS "This project requires the CGAL library, and will not be compiled.")
return()
endif()
# include helper file
include( ${CGAL_USE_FILE} )
# Boost and its components
find_package( Boost REQUIRED )
if ( NOT Boost_FOUND )
message(STATUS "This project requires the Boost library, and will not be compiled.")
return()
endif()
# include for local directory
# include for local package
include_directories( BEFORE ../include )
# Creating entries for target: delaunay
# ############################
add_executable( delaunay delaunay.cpp )
add_to_cached_list( CGAL_EXECUTABLE_TARGETS delaunay )
# Link the executable to CGAL and third-party libraries
target_link_libraries(delaunay ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} )
Anyone have a clue what could be wrong?
Indeed that CMakeLists.txt does not try to find Boost libraries and headers. That is why the Boost_DEBUG variable has no effect. It seems that the CGAL libraries configuration was not correct. You should rerun CMake in your build directory of CGAL libraries, and check that there is no error.
Related
I'm trying to solve the problem, but nothing works. I don't understand why gcc looks for "-llib/cmocka.dll" when it should look for "cmocka.dll". Cmocka downloaded and showed the path to it. I tried to find a solution to the problem on the forums, but the same problem was described there on linux, and I have windows.I would appreciate any help as I don't know what to do anymore.
program structure:
root CMakeLists:
cmake_minimum_required(VERSION 3.7)
project(tests LANGUAGES C ASM)
set(CMAKE_C_STANDARD 99)
add_subdirectory(src)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")
# cmocka
find_package(CMocka CONFIG)
if (CMocka_FOUND)
message("cmocka found")
include(AddCMockaTest)
include(AddMockedTest)
add_subdirectory(test)
enable_testing()
endif(CMocka_FOUND)
AddCMockaTest:
enable_testing()
include(CTest)
if (CMAKE_CROSSCOMPILING)
if (WIN32)
find_program(WINE_EXECUTABLE
NAMES wine)
set(TARGET_SYSTEM_EMULATOR ${WINE_EXECUTABLE} CACHE INTERNAL "")
endif()
endif()
function(ADD_CMOCKA_TEST _TARGET_NAME)
set(one_value_arguments
)
set(multi_value_arguments
SOURCES
COMPILE_OPTIONS
COMPILE_DEFINITION
LINK_LIBRARIES
LINK_OPTIONS
)
cmake_parse_arguments(_add_cmocka_test
""
"${one_value_arguments}"
"${multi_value_arguments}"
${ARGN}
)
if (NOT DEFINED _add_cmocka_test_SOURCES)
message(FATAL_ERROR "No sources provided for target ${_TARGET_NAME}")
endif()
add_executable(${_TARGET_NAME} ${_add_cmocka_test_SOURCES})
if (DEFINED _add_cmocka_test_COMPILE_OPTIONS)
target_compile_options(${_TARGET_NAME}
PRIVATE ${_add_cmocka_test_COMPILE_OPTIONS}
)
endif()
if (DEFINED _add_cmocka_test_LINK_LIBRARIES)
target_link_libraries(${_TARGET_NAME}
PRIVATE ${_add_cmocka_test_LINK_LIBRARIES}
)
endif()
if (DEFINED _add_cmocka_test_LINK_OPTIONS)
set_target_properties(${_TARGET_NAME}
PROPERTIES LINK_FLAGS
${_add_cmocka_test_LINK_OPTIONS}
)
endif()
add_test(${_TARGET_NAME}
${TARGET_SYSTEM_EMULATOR} ${_TARGET_NAME}
)
endfunction (ADD_CMOCKA_TEST)
AddMockedTest:
function(add_mocked_test name)
# parse arguments passed to the function
set(options )
set(oneValueArgs )
set(multiValueArgs SOURCES MOCKS COMPILE_OPTIONS LINK_LIBRARIES LINK_OPTIONS)
cmake_parse_arguments(ADD_MOCKED_TEST "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN} )
# create link flags for mocks
set(link_flags "")
foreach (mock ${ADD_MOCKED_TEST_MOCKS})
set(link_flags "${link_flags} -Wl,--wrap=${mock}")
endforeach(mock)
# define test
add_cmocka_test(test_${name}
SOURCES test_${name}.c ${ADD_MOCKED_TEST_SOURCES}
COMPILE_OPTIONS ${DEFAULT_C_COMPILE_FLAGS}
${ADD_MOCKED_TEST_COMPILE_OPTIONS}
LINK_LIBRARIES ${CMOCKA_LIBRARIES}
${ADD_MOCKED_TEST_LINK_LIBRARIES}
LINK_OPTIONS ${link_flags} ${ADD_MOCKED_TEST_LINK_OPTIONS})
# allow using includes from src/ directory
target_include_directories(test_${name} PRIVATE ${CMAKE_SOURCE_DIR}/src)
endfunction(add_mocked_test)
I'd like to use google protobuf (master branch) + bazel v4.2.1 to set up communication between C++ and python parts of my program. I've got the following WORKSPACE file:
load("#bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "com_google_protobuf",
strip_prefix = "protobuf-master",
urls = ["https://github.com/protocolbuffers/protobuf/archive/master.zip"],
)
load("#com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()
and the BUILD file:
load("#com_google_protobuf//:protobuf.bzl", "cc_proto_library")
load("#com_google_protobuf//:protobuf.bzl", "py_proto_library")
cc_proto_library(
name = "container_cc_proto",
srcs = ["container.proto"],
visibility = ["//visibility:public"],
deps = ["#com_google_protobuf//:any_proto",],
)
py_proto_library(
name = "container_py_proto",
srcs = ["container.proto"],
visibility = ["//visibility:public"],
deps = ["#com_google_protobuf//:any_proto",],
)
The container.proto tries to include "google/protobuf/any.proto". On my command bazel build //:container_cc_proto I see the following error:
ERROR: /home/*user*/sandbox/bypass/BUILD:31:17: no such target '#com_google_protobuf//:any_proto_genproto': target 'any_proto_genproto' not declared in package '' defined by /home/*some path*/external/com_google_protobuf/BUILD and referenced by '//:container_cc_proto_genproto'
Could anyone please tell me how to include any.proto correctly, or any other known workarounds. Thanks!
I'm using bazel 4.1.0 to build to project.
Current set up:
go.mod file
...
github.com/mwitkow/go-proto-validators v0.3.2 // indirect
...
WORKSPACE file
load("#bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
load("//:repositories.bzl", "go_repositories")
go_repositories()
in repositories.blz file
...
go_repository(
name = "com_github_mwitkow_go_proto_validators",
importpath = "github.com/mwitkow/go-proto-validators",
sum = "h1:qRlmpTzm2pstMKKzTdvwPCF5QfBNURSlAgN/R+qbKos=",
version = "v0.3.2",
)
....
in students/api.v1/api.proto file
import "google/api/annotations.proto";
import "github.com/mwitkow/go-proto-validators/validator.proto";
after running bazel run //:gazelle -- update-repos -from_file=go.mod -to_macro=repositories.bzl%go_repositories -prune=true and bazel run //:gazelle
it generate students/api.v1/BUILD.bazel file
proto_library(
name = "api_proto",
srcs = ["api.proto"],
visibility = ["//visibility:public"],
deps = [
"//github.com/mwitkow/go-proto-validators:validators_proto",
"#go_googleapis//google/api:annotations_proto",
],
)
go_proto_library(
name = "api_go_proto",
compilers = ["#io_bazel_rules_go//proto:go_grpc"],
importpath = "students/generated/api",
proto = ":api_proto",
visibility = ["//visibility:public"],
deps = [
"//github.com/mwitkow/go-proto-validators:validator_proto",
"#go_googleapis//google/api:annotations_go_proto",
],
)
When I run bazel build //..., it produces an error
ERROR: /my-app/students/api.v1/BUILD.bazel:15:17: no such package 'github.com/mwitkow/go-proto-validators': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.
- /my-app/github.com/mwitkow/go-proto-validators and referenced by '/students/api.v1:api_go_proto'
ERROR: Analysis of target '//students/api.v1:api' failed; build aborted: Analysis failed
I would like to make the build work without error. Thank you very much for your help.
I think in BUILD.bazel file, //github.com/mwitkow/go-proto-validators:validators_proto should be #github.com/mwitkow/go-proto-validators:validators_proto, like #go_googleapis//google/api:annotations_proto but it's just a vague idea.
I want to link a framework, that I made myself called VideoCapturer, to another project through its VideoCapturerConfig.cmake.
But I can't get the "usage requirement" / "target_link_libraries" correctly.
When I give the full path, hardcoded, to the location of the install framework, it works!
target_link_libraries( myprojectA
PUBLIC -framework /install/path/to/videocapturer.framework )
I would rather do that with a target provided by find_package() for more robustness.
Here is the piece of CMake I wrote to build and install the framework
# MyVideoCapturer framework
project( MyVideoCapturer )
### General variables
set( myvideocapturer_targets_export_name "${CMAKE_PROJECT_NAME}Targets" )
set( myvideocapturer_config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}" )
set( myvideocapturer_project_config "${CMAKE_PROJECT_NAME}Config.cmake" )
set( myvideocapturer_version_config "${CMAKE_PROJECT_NAME}ConfigVersion.cmake" )
add_library( VideoCapturer "" )
add_library( MyVideoCapturer::VideoCapturer ALIAS VideoCapturer )
add_subdirectory( src ) # Mostly target_sources( VideoCapturer PRIVATE someSrcFiles.cpp )
list( APPEND _pubheaders "macVideoCapturer/VideoCapturer.h" )
set_target_properties( VideoCapturer PROPERTIES
FRAMEWORK TRUE
PUBLIC_HEADER "${_pubheaders}"
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer"
)
### Install targets, headers and export
include( GNUInstallDirs )
install(
TARGETS VideoCapturer
EXPORT "${myvideocapturer_targets_export_name}"
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(
EXPORT "${myvideocapturer_targets_export_name}"
DESTINATION "${myvideocapturer_config_install_dir}"
NAMESPACE MyVideoCapturer::
FILE ${myvideocapturer_targets_export_name}.cmake
)
### Config file for Packaging
include( CMakePackageConfigHelpers )
configure_package_config_file(
"Config.cmake.in"
"${myvideocapturer_project_config}"
INSTALL_DESTINATION ${myvideocapturer_config_install_dir}
PATH_VARS
myvideocapturer_config_install_dir
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
in my Config.cmake.in
#PACKAGE_INIT#
include( "${CMAKE_CURRENT_LIST_DIR}/#myvideocapturer_targets_export_name#.cmake" )
After installation of that framework :
in MyVideoCapturerTargets.cmake :
# Create imported target CppMacVideoCapturer::VideoCapturer
add_library(CppMacVideoCapturer::VideoCapturer SHARED IMPORTED)
set_property(TARGET CppMacVideoCapturer::VideoCapturer PROPERTY FRAMEWORK 1)
to my understanding, 2 lines should be enough to get it right :
find_package( myvideocapturer REQUIRED )
target_link_libraries( myprojectA
PUBLIC -framework videocapturer )
when I try that, the project can't find the headers located in Videocapturer.framework/Headers
and if I try :
target_link_libraries( myprojectA
PUBLIC -framework MyVideoCapturer::myvideocapturer )
CMake doesn't find the target.
Any idea how can I export my framework ?
Thanks a lot
EDIT
Thanks to tsyvarev I found a way to solve it. I am not sure if this is the "proper" way to do it though.
In the base project :
if( APPLE )
target_include_directories( VideoCapturer
PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_LIBDIR}/VideoCapturer.framework>
)
else() # Framework is Apple-only
target_include_directories( VideoCapturer
PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
endif()
EDIT 1/4/19 : the right way seems to do :
target_include_directories( VideoCapturer
PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_LIBDIR}/VideoCapturer.framework>
)
last edit : Please read my own answer
The right way to install / export or package a framework is something like this : https://github.com/forexample/ios-dynamic-framework
However, it does contain a workaround, there is no find_package
This repository has a lot of good examples for "modern" CMake. check it out!
I tried to compile MEPP library. I created a find module "FindCGAL.cmake" as follow:
IF(CGAL_INCLUDE_DIR AND CGAL_LIBRARIES)
SET(CGAL_FOUND TRUE)
ELSE(CGAL_INCLUDE_DIR AND CGAL_LIBRARIES)
FIND_PATH(CGAL_INCLUDE_DIR basic.h
/scratch/softs/cgal/4.3.0/64/sequential/gcc/4.4.7/include/CGAL
$ENV{ProgramFiles}/CGAL/*/include/CGAL
$ENV{SystemDrive}/CGAL/*/include/CGAL
)
FIND_LIBRARY(CGAL_LIBRARIES NAMES CGAL libCGAL
PATHS
/scratch/softs/cgal/4.3.0/64/sequential/gcc/4.4.7/lib
/scratch/softs/cgal/4.3.0/64/sequential/gcc/4.4.7/lib/CGAL
$ENV{ProgramFiles}/CGAL/*/lib/ms
$ENV{SystemDrive}/CGAL/*/lib/ms
)
IF(CGAL_INCLUDE_DIR AND CGAL_LIBRARIES)
SET(CGAL_FOUND TRUE)
MESSAGE(STATUS "Found CGAL. New Hossein: ${CGAL_INCLUDE_DIR}, ${CGAL_LIBRARIES}")
INCLUDE_DIRECTORIES(${CGAL_INCLUDE_DIR} $ENV{CGAL_CFG})
ELSE(CGAL_INCLUDE_DIR AND CGAL_LIBRARIES)
SET(CGAL_FOUND FALSE)
MESSAGE(STATUS "CGAL not found. New Hossein")
ENDIF(CGAL_INCLUDE_DIR AND CGAL_LIBRARIES)
ENDIF(CGAL_INCLUDE_DIR AND CGAL_LIBRARIES)
and in the CMakeList.txt:
# Find CGAL libraries
FIND_PACKAGE(CGAL COMPONENTS Core)
IF(CGAL_FOUND)
INCLUDE(${CGAL_USE_FILE})
MESSAGE(STATUS "Found CGAL: ${CGAL_LIBRARIES}")
MESSAGE(STATUS "Found CGAL 3RD PARTY LIBRARIES: ${CGAL_3RD_PARTY_LIBRARIES}")
ELSE(CGAL_FOUND)
MESSAGE(FATAL_ERROR "CGAL not found. Please set CGAL_DIR.")
ENDIF(CGAL_FOUND)
During compilation I receive the following CMakeError:
CMake Error at src/components/Analysis/Curvature/CMakeLists.txt:48 (INCLUDE):
include called with wrong number of arguments. Include only takes one
file.
any help will be appreciated.
You forgot to set "CGAL_USE_FILE".