How to configure a complex project with CMake Tools plugin? - cmake

I am trying to configure vscode to develop llvm/mlir project with the CMake Tools plugin.
The project is big and requires passing this configuration to the command-line:
git clone https://github.com/llvm/llvm-project.git
mkdir llvm-project/build
cd llvm-project/build
cmake -G Ninja ../llvm \
-DLLVM_ENABLE_PROJECTS=mlir \
-DLLVM_BUILD_EXAMPLES=ON \
-DLLVM_TARGETS_TO_BUILD="X86;NVPTX;AMDGPU" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DLLVM_ENABLE_LLD=ON \
-DPYTHON_EXECUTABLE=python3
I tried to add this information into .vscode/settings.json:
{
"cmake.sourceDirectory": "${workspaceFolder}/llvm",
"cmake.configureArgs": [
"-DLLVM_ENABLE_PROJECTS=mlir",
"-DLLVM_BUILD_EXAMPLES=ON",
"-DLLVM_TARGETS_TO_BUILD='X86;NVPTX;AMDGPU'",
"-DCMAKE_BUILD_TYPE=Release",
"-DLLVM_ENABLE_ASSERTIONS=ON",
"-DCMAKE_C_COMPILER=clang",
"-DCMAKE_CXX_COMPILER=clang++",
"-DLLVM_ENABLE_LLD=ON",
"-DPYTHON_EXECUTABLE=python3",
]
}
But the configuration is not successful and it appears that my arguments were not detected.
[main] Configuring folder: llvm-project
[proc] Executing command: /usr/bin/cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=/bin/clang-10 -DCMAKE_CXX_COMPILER:FILEPATH=/bin/clang++-10 -H${HOME}/Development/mlir/llvm-project/mlir -B${HOME}/Development/mlir/llvm-project/build -G Ninja
[cmake] Not searching for unused variables given on the command line.
[cmake] CMake Warning (dev) in CMakeLists.txt:
[cmake] No project() command is present. The top-level CMakeLists.txt file must
[cmake] contain a literal, direct call to the project() command. Add a line of
[cmake] code such as
[cmake]
[cmake] project(ProjectName)
[cmake]
[cmake] near the top of the file, but after cmake_minimum_required().
[cmake]
[cmake] CMake is pretending there is a "project(Project)" command on the first
[cmake] line.
[cmake] This warning is for project developers. Use -Wno-dev to suppress it.
[cmake]
[cmake] -- The C compiler identification is Clang 10.0.0
[cmake] -- The CXX compiler identification is Clang 10.0.0
[cmake] -- Check for working C compiler: /bin/clang-10
[cmake] -- Check for working C compiler: /bin/clang-10 -- works
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Detecting C compile features
[cmake] -- Detecting C compile features - done
[cmake] -- Check for working CXX compiler: /bin/clang++-10
[cmake] -- Check for working CXX compiler: /bin/clang++-10 -- works
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] CMake Warning (dev) at CMakeLists.txt:26 (if):
[cmake] Policy CMP0057 is not set: Support new IN_LIST if() operator. Run "cmake
[cmake] --help-policy CMP0057" for policy details. Use the cmake_policy command to
[cmake] set the policy and suppress this warning.
[cmake]
[cmake] IN_LIST will be interpreted as an operator when the policy is set to NEW.
[cmake] Since the policy is not set the OLD behavior will be used.
[cmake] This warning is for project developers. Use -Wno-dev to suppress it.
[cmake]
[cmake] CMake Error at CMakeLists.txt:26 (if):
[cmake] if given arguments:
[cmake]
[cmake] "NVPTX" "IN_LIST" "LLVM_TARGETS_TO_BUILD"
[cmake]
[cmake] Unknown arguments specified
[cmake]
[cmake]
[cmake] CMake Warning (dev) in CMakeLists.txt:
[cmake] No cmake_minimum_required command is present. A line of code such as
[cmake]
[cmake] cmake_minimum_required(VERSION 3.16)
[cmake]
[cmake] should be added at the top of the file. The version specified may be lower
[cmake] if you wish to support older CMake versions for this project. For more
[cmake] information run "cmake --help-policy CMP0000".
[cmake] This warning is for project developers. Use -Wno-dev to suppress it.
[cmake]
[cmake] -- Configuring incomplete, errors occurred!
[cmake] See also "${HOME}/Development/mlir/llvm-project/build/CMakeFiles/CMakeOutput.log".
How can I transform the configuration line into something that the CMake Tools plugin can understand?
EDIT: Adjusted the error message
EDIT2:
Modifying .vscode/settings.json to use cmake.configureSettings did not solve the problem:
{
"cmake.sourceDirectory": "${workspaceFolder}/llvm",
"cmake.configureSettings": {
"LLVM_ENABLE_PROJECTS" : "mlir",
"LLVM_BUILD_EXAMPLES" : "ON",
"LLVM_TARGETS_TO_BUILD" : "\"X86;NVPTX;AMDGPU\"",
"CMAKE_BUILD_TYPE" : "Release",
"LLVM_ENABLE_ASSERTIONS" : "ON",
"CMAKE_C_COMPILER" : "clang",
"CMAKE_CXX_COMPILER" : "clang++",
"LLVM_ENABLE_LLD" : "ON",
"PYTHON_EXECUTABLE" : "python3",
}
}

I found the problem / possible bug.
It appears that vscode and CMake Tools plugin caches some files and even if you delete the build folder (that holds the CMakeCache.txt) the project does not use new configurations parameters modified on .vscode/settings.json.
So, to get my project working.
I added this information to .vscode/seetings.json:
{
"cmake.sourceDirectory": "${workspaceFolder}/llvm",
"cmake.configureSettings": {
"LLVM_ENABLE_PROJECTS" : "mlir",
"LLVM_BUILD_EXAMPLES" : "ON",
"LLVM_TARGETS_TO_BUILD" : "X86;NVPTX;AMDGPU",
"CMAKE_BUILD_TYPE" : "Release",
"LLVM_ENABLE_ASSERTIONS" : "ON",
"CMAKE_C_COMPILER" : "clang",
"CMAKE_CXX_COMPILER" : "clang++",
"LLVM_ENABLE_LLD" : "ON",
"PYTHON_EXECUTABLE" : "python3",
}
}
Closed vscode
Deleted the build folder
Opened vscode
Answered yes to: "Would you like to configure project 'llvm-project'?"
And the configuration was successful.
Now you can select your targets using vscode.
Unfortunately it appears that every time vscode is opened the CMake plugin triggers a new configuration, but it is probably better to address this issue in another question/forum.

In .vscode/seetings.json, use an array syntax to specify multiple options instead. For example,
{
"cmake.sourceDirectory": "${workspaceFolder}/llvm",
"cmake.configureSettings": {
//...
"LLVM_TARGETS_TO_BUILD" : ["X86", "NVPTX", "AMDGPU"],
//...
}
}

Related

MinGW on Windows: cmake arguments to find wxWidgets?

Similar questions already exist but I haven't found an answer that works.
I need to build a wxWidgets project in Windows using MinGW, I would like to use the cmake command from the command line (I installed mingw, cmake and bash using chocolatey)
I would like to avoid compiling wxWidgets so I am using the pre-built binaries MinGW-w64 10.2 (Headers + Dev x64 + Release x64), I unpack them to C:\wxWidgets-3.1.5
I've tried a number of combinations of arguments for cmake but haven't found one that works on the first run, I say first run because I've found one that works on the second:
cmake .. -G "MinGW Makefiles" \
-DwxWidgets_ROOT_DIR=/c/wxWidgets-3.1.5/ \
-DwxWidgets_LIB_DIR=/c/wxWidgets-3.1.5/lib/gcc1020_x64_dll/
I am not a cmake expert but I imagine that by specifying these arguments in the first run they are cached and in the second run they are used, bypassing the search.
What I would like to know is what arguments I have to give to get them to be found correctly, _CONFIGURATION, _ROOT_DIR, _LIBRARIES, _INCLUDE_DIRS don't seem to have any effect.
↓ edit ↓
CMakelists.txt:
cmake_minimum_required(VERSION 3.18)
project(Test)
set(wxWidgets_USE_LIBS)
find_package(wxWidgets REQUIRED)
if(wxWidgets_FOUND)
include(${wxWidgets_USE_FILE})
add_executable(MyTest WIN32 main.cpp)
target_link_libraries(MyTest ${wxWidgets_LIBRARIES})
else(wxWidgets_FOUND)
message("wxWidgets not found!")
endif(wxWidgets_FOUND)
command line used:
cmake .. -G "MinGW Makefiles" -DwxWidgets_ROOT_DIR=/c/wxWidgets-3.1.5/ -DwxWidgets_LIB_DIR=/c/wxWidgets-3.1.5/lib/gcc1020_x64_dll/ -DwxWidgets_wxrc_EXECUTABLE=/c/wxWidgets-3.1.5/lib/gcc1020_x64_dll/wxrc.exe -DCMAKE_BUILD_TYPE=Release -DwxWidgets_LIBRARIES=/c/wxWidgets-3.1.5/lib/gcc1020_x64_dll/ -DwxWidgets_INCLUDE_DIRS=/c/wxWidgets-3.1.5/include/
first run:
-- The C compiler identification is GNU 10.2.0
-- The CXX compiler identification is GNU 10.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/ProgramData/chocolatey/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/ProgramData/chocolatey/bin/g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Could NOT find wxWidgets (missing: wxWidgets_LIBRARIES wxWidgets_INCLUDE_DIRS core base)
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/Alex/Documents/Progetti/wx-test/build
wxWidgets not found!
second run:
-- Found wxWidgets: debug;C:/wxWidgets-3.1.5/lib/gcc1020_x64_dll/libwxmsw31ud_core.a;optimized;C:/wxWidgets-3.1.5/lib/gcc1020_x64_dll/libwxmsw31u_core.a;debug;C:/wxWidgets-3.1.5/lib/gcc1020_x64_dll/libwxbase31ud.a;optimized;C:/wxWidgets-3.1.5/lib/gcc1020_x64_dll/libwxbase31u.a;debug;C:/wxWidgets-3.1.5/lib/gcc1020_x64_dll/libwxbase31ud_net.a;optimized;C:/wxWidgets-3.1.5/lib/gcc1020_x64_dll/libwxbase31u_net.a;debug;C:/wxWidgets-3.1.5/lib/gcc1020_x64_dll/libwxpngd.a;optimized;C:/wxWidgets-3.1.5/lib/gcc1020_x64_dll/libwxpng.a;debug;C:/wxWidgets-3.1.5/lib/gcc1020_x64_dll/libwxtiffd.a;optimized;C:/wxWidgets-3.1.5/lib/gcc1020_x64_dll/libwxtiff.a;debug;C:/wxWidgets-3.1.5/lib/gcc1020_x64_dll/libwxjpegd.a;optimized;C:/wxWidgets-3.1.5/lib/gcc1020_x64_dll/libwxjpeg.a;debug;C:/wxWidgets-3.1.5/lib/gcc1020_x64_dll/libwxzlibd.a;optimized;C:/wxWidgets-3.1.5/lib/gcc1020_x64_dll/libwxzlib.a;debug;C:/wxWidgets-3.1.5/lib/gcc1020_x64_dll/libwxregexud.a;optimized;C:/wxWidgets-3.1.5/lib/gcc1020_x64_dll/libwxregexu.a;debug;C:/wxWidgets-3.1.5/lib/gcc1020_x64_dll/libwxexpatd.a;optimized;C:/wxWidgets-3.1.5/lib/gcc1020_x64_dll/libwxexpat.a;winmm;comctl32;uuid;oleacc;uxtheme;rpcrt4;shlwapi;version;wsock32 (found version "3.1.5") found components: core base net png tiff jpeg zlib regex expat
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/Alex/Documents/Progetti/wx-test/build
if I use find_package(wxWidgets REQUIRED):
CMake Error at C:/Program Files/CMake/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find wxWidgets (missing: wxWidgets_LIBRARIES
wxWidgets_INCLUDE_DIRS)
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/CMake/share/cmake-3.21/Modules/FindwxWidgets.cmake:1025 (find_package_handle_standard_args)
CMakeLists.txt:24 (find_package)
Thanks to Process Monitor I noticed that FindwxWidgets.cmake looks for libraries in gcc_dll/ (not gcc2010_x64_dll/), once the directory was renamed cmake -G "MinGW Makefiles" -DwxWidgets_ROOT_DIR=/c/wxWidgets-3.1.5 was enough to find the directory on the first run.

Cmake linking shared library from project path

I'm trying to configure cmake for c++ project and link my library. For some reason, I can't make cmake find my library in ./lib// folder. According to the documentation, the library search path should be /lib/.
I have tried with empty prefix and with "./" and in neither case my library is found.
If I give HINT in find_library(), then it is found, but why isn't it found without the hint?
This is my CMakeList.txt:
cmake_minimum_required(VERSION 3.0.0)
project(UntitledProject VERSION 0.1.0)
include(CTest)
enable_testing()
message("ARCH: " ${CMAKE_LIBRARY_ARCHITECTURE})
message("PREFIX: " ${CMAKE_PREFIX_PATH})
message("LIB: " ${CMAKE_LIBRARY_PATH})
find_library(LIBMYLIB mylibrary)
message("MYLIB: " ${LIBMYLIB})
add_executable(UntitledProject main.cpp)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
Shared library indeed exists:
$ file lib/x86_64-linux-gnu/libmylibrary.so
lib/x86_64-linux-gnu/libmylibrary.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=e34ba5ae24d6a09bfb847a46cd669ea7e101e8a4, stripped
This is the cmake configure output:
[cmake] The C compiler identification is GNU 7.5.0
[cmake] The CXX compiler identification is GNU 7.5.0
[cmake] Check for working C compiler: /usr/bin/x86_64-linux-gnu-gcc-7
[cmake] Check for working C compiler: /usr/bin/x86_64-linux-gnu-gcc-7 -- works
[cmake] Detecting C compiler ABI info
[cmake] Detecting C compiler ABI info - done
[cmake] Detecting C compile features
[cmake] Detecting C compile features - done
[cmake] Check for working CXX compiler: /usr/bin/x86_64-linux-gnu-g++-7
[cmake] Check for working CXX compiler: /usr/bin/x86_64-linux-gnu-g++-7 -- works
[cmake] Detecting CXX compiler ABI info
[cmake] Detecting CXX compiler ABI info - done
[cmake] Detecting CXX compile features
[cmake] Detecting CXX compile features - done
[cmake] ARCH: x86_64-linux-gnu
[cmake] PREFIX:
[cmake] LIB:
[cmake] MYLIB: LIBMYLIB-NOTFOUND
[cmake] Configuring done
[cmake] Generating done
What am I missing?
Perhaps you could try setting CMAKE_PREFIX_PATH using absolute path from command line instead of ./
If I give HINT in find_library(), then it is found, but why isn't it found without the hint?
Because, by default find_library searches in a system path, which in Linux is usually /usr/lib or /usr/local/lib.
To fix, you can create a symlink from lib/x86_64-linux-gnu/ to /usr/local/lib:
sudo ln -s lib/x86_64-linux-gnu/libmylibrary.so /usr/local/lib/libmylibrary.so

How to build Aseprite from source in ubuntu 20.04? CMake Warning: "No source or binary directory provided"

I was trying to build Aseprite from its source in Ubuntu 20.04 and got stuck while executing cmake.
I followed all the instructions provided in the install.md file.
This is the output I got after executing cmake :
CMake Warning:
No source or binary directory provided. Both will be assumed to be the
same as the current working directory, but note that this warning will
become a fatal error in future CMake releases.
CMake Deprecation Warning at CMakeLists.txt:16 (cmake_policy):
The OLD behavior for policy CMP0046 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
CMake Error at /usr/share/cmake-3.16/Modules/CMakeCInformation.cmake:84 (include):
include could not find load file:
/home/shree/aseprite/build/laf/cmake/c_flag_overrides.cmake
Call Stack (most recent call first):
CMakeLists.txt:31 (project)
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
CMake Error at /usr/share/cmake-3.16/Modules/CMakeCXXInformation.cmake:89 (include):
include could not find load file:
/home/shree/aseprite/build/laf/cmake/cxx_flag_overrides.cmake
Call Stack (most recent call first):
CMakeLists.txt:31 (project)
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:41 (message):
Your Aseprite repository is incomplete, initialize submodules using:
git submodule update --init --recursive
-- Configuring incomplete, errors occurred!
See also "/home/shree/aseprite/build/CMakeFiles/CMakeOutput.log".
This error happens because the 'laf' folder is empty. You must download this project from Github and put the content inside that folder.
https://github.com/aseprite/laf/tree/8f91e164d1d23a3b0dc751bc0f9185af27dcb2c7

Why is this find_package failing in newer CMake versions?

I am experiencing a problem in a project, when upgrading from CMake 3.8 to 3.14. I have reduced this to the following issue. Note that project is before find_package (the other way around I do not have the issue I am describing).
cmake_minimum_required(VERSION 3.2.1)
find_package(MPI REQUIRED)
project(Test CXX)).
When I build with CMake 3.8, the output is as follows:
build3_8$ cmake ../source/
-- The CXX compiler identification is Intel 17.0.5.20170817
-- Check for working CXX compiler: (...)/linux/bin/intel64/icpc
-- Check for working CXX compiler: (...)/linux/bin/intel64/icpc -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: (...)/build3_8
With CMake 3.14 I get the following output:
build3_14$ cmake ../source/
CMake Error at (...)/CMake/3.14.0/share/cmake-3.14/Modules/FindPackageHandleStandardArgs.cmake:211 (message):
No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()
Call Stack (most recent call first):
(...)/CMake/3.14.0/share/cmake-3.14/Modules/FindMPI.cmake:1672 (find_package_handle_standard_args)
CMakeLists.txt:3 (find_package)
-- Configuring incomplete, errors occurred!
I wonder why this is happening with the newer CMake version (although FindMPI.cmake is completely different)?
Also, what can I do to solve this? Do I need to write my own config?
(I cannot just change the order of project and find_package, because wrappers are created for the compilers (not my choice, please don't blame me))

Cmake not able to recognize cache entry for FOLLY_LIBRARIES while installing fbtorch using luarocks

I am trying to install fbtorch on linux. However, when I try to run luarocks install fbtorch I get the following error.
cmake -E make_directory build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="/home/user/torch/install/bin/.." -DCMAKE_INSTALL_PREFIX="/home/user/torch/install/lib/luarocks/rocks/fbtorch/scm-1"
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Torch7 in /home/user/torch/install
CMake Error at /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
REQUIRED_ARGS (missing: FOLLY_INCLUDE_DIR FOLLY_LIBRARIES)
Call Stack (most recent call first):
/usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
cmake/FindFolly.cmake:23 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:12 (FIND_PACKAGE)
-- Configuring incomplete, errors occurred!
See also "/tmp/luarocks_fbtorch-scm-1-4920/fbtorch/build/CMakeFiles/CMakeOutput.log".
Now, to fix the REQUIRED_ARGS (missing: FOLLY_INCLUDE_DIR FOLLY_LIBRARIES) I changed the cmake command to:
cmake -E make_directory build && cd build && cmake .. -DFOLLY_LIBRARIES="/home/user/local/lib" -DFOLLY_INCLUDE_DIR="/home/user/local/include" -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$(LUA_BINDIR)/.." -DCMAKE_INSTALL_PREFIX="$(PREFIX)"
Kindly note that I have compiles and installed folly at /home/user/local/ in appropriate directories
This fixed the FOLLY_INCLUDE_DIR error but its still showing error for FOLLY_LIBRARIES like so:
CMake Error at /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
REQUIRED_ARGS (missing: FOLLY_LIBRARIES)
Call Stack (most recent call first):
/usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
cmake/FindFolly.cmake:23 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:12 (FIND_PACKAGE)
What am I missing here? Why did the cmake recognize the cache entry for FOLLY_INCLUDE_DIR but not for FOLLY_LIBRARIES?
Variables listed in "missed" list in find_package() call are not required to be CACHE ones. So, setting cache variable with the same name may do not resolve the problem.
If searched package is actually installed into non-standard location, instead of blindly setting "missing" variables it is better to hint the "Find" script about that location.
Many "Find" scripts describe possible ways of parametrization at the beginning of their code. Aside from this, there are common ways for hinting "Find" scripts about actual location of the package; these ways works for most of scripts. E.g. you may add install location of the package into CMAKE_PREFIX_PATH variable (See that question).
If you look at FindFolly.cmake you can see the line -
SET(FOLLY_LIBRARIES ${FOLLY_LIBRARY})
This means that FOLLY_LIBRARIES is being set but it needs FOLLY_LIBRARY.
So in your command line change -DFOLLY_LIBRARIES to -DFOLLY_LIBRARY